Developing a website… ; Open up “notepad++”, browse to your web server via FTP and edit the files. Then refresh to see the changes…
Sounds familiar? Probably… It’s a very straight forward and easy process. The downside however is that you have no tracking of your changes (Version Control) and that the process is pretty manual. So this becomes a problem when you aren’t the only one on the job or if something goes wrong.
So let’s step it up and introduce “version control”… Now we have an overview of all the revisions we made to our code and we are able to revert back to it. Yet suddenly, we need to do a lot more to get our code onto the web server. This brings us to the point where we want a kind of helper that does the “deployment” for us.
- Local Development : The development will happen here. Have fun… When you (think you) are happy with what you have produced, you update the files via your version system.
- Source Repository : The source repository will contain all the versions of your code. Here you can configure it to send a notification to your deployment system whenever a new version has been introduced.
- Deployment System : The deployment system will query the source repository and retrieve the latest code. This code will be packaged, transmitted and deployed onto the target system(s).
- Target Systems : The systems that will actually host your code and deliver the (web) service!
Real Life Example?
- Development : A basic windows workstation with notepad++ & sourcetree.
- Source Repository : Bitbucket
- Deployent System : DeployHQ
- Target System : A web server with an FTP interface & LAMP-install.
- Create a private repository at BitBucket
- Pull/push the repository between BitBucket & your local SourceTree
- In GitHub, go to “Settings”, “Deployment Keys” and generate a key for your automation. Copy it to your clipboard…
- In DeployHQ, go to “Settings”, “General Settings” and copy to key into the “Public Key Authentication” textbox.
- In DeployHQ, go to “Settings”, “Servers & Group” and create a new server.
- In the same screen, Enable “Auto Deploy” and copy the url hook.
- Now go to “Settings” in GitHub, and then “Hooks”. Add a “POST” hook containing the url hook you just copied.
- Now every time you do a commit on your workstation, the code will be deployed to your server!
In fact, this is the mechanism I utilize for my own (hobby) development projects. An example of here, is my own homepage, which is deployed via the system as described above.