I have a site running on django, (but the question applies to anything, php, etc)
Currently I'm using unison to deploy my changes, and I (kinda used to) love it because before that I was doing it manually!!
Now, as I'm getting my feet wet with git, I'm starting to love it! And I'm thinking if maybe I should use it instead of unison to deploy my changes!
This way I'll have the added benefit of being able to revert my changes if somehow deploying them turned out to be a disaster!
The question is:
Is git suitable for deploying websites?
Any things/issues/gotchas that I should be aware of?
You can run your deployment workflow on GitHub-hosted runners or on self-hosted runners. Traffic from GitHub-hosted runners can come from a wide range of network addresses.
Deploying with git pull When setting up Git deployment to work with git pull , the setup is as follows: the server which runs the application also hosts a clone of the Git repository with the code. When it's time to deploy, you run git pull on the server to fetch the latest version of the app.
I use git to track my website, and I deploy it like this:
git archive --format=tar --prefix="homepage/" master | gzip | ssh webserver "tar xvz -C ~/public_html"
This deserves a little explanation. The archive command for git will export the files for the master branch, which gets compressed with gzip to minimize network traffic. It's received remotely over ssh, which is decompressed into the final destination directory.
The deploy script that I use has a little more going on, but this is the most important piece.
You can take a look at Fabric, popular among Djangonauts...
If the question is if you can you use git to deploy your django application, the answer is sure!
However, production deployment of a popular application can become complex - and go way beyond just rolling back files. You may need to run DB scripts (both upgrade and downgrade scripts), restart cron jobs, or move files around.
As part of your deployment process you may want to back up your code base in its entirety so that you can rollback any number of versions back.
One way to do this is with Capistrano which automates the entire deployment process for you. You author scripts in your development environment and issue commands like: cap deploy, cap deploy_with_migrations, cap rollback, etc. and everything is automated from the login all the way up to the backup process and running DB scripts. By having the deployment automated you eliminate errors in your production environment. I recently spoke to an organization who accidentally deleted their entire database while in the midst of a deployment and needed to restore everything from backups. Deployment errors can really break your business so you want to automate this if you are serious about it.
Though Capistrano is a Ruby-based deployment tool commonly used with Rails, it's agnostic in terms of its automation capabilities. There are numerous posts on the Internet that discuss the benefits of deploying Django apps with Capistrano (google - django capistrano).
You can also check check out this link here
Well, I use SVN to deploy my website, so I'd say go for it! Keep in mind that you may have to restart/reload the server every time you update the code for the website (I'm not sure if Django or whatever you're running it on is able to work around that).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With