My $4/year continuous deployment server using webhook and rsync

Anthony Smith is running an interesting project called Low End Spirit where he sells low end servers for $4/year and these servers comes with 128Mb ram and one core of Xeon X3440 cpu @2.53GHz and 500GB bandwidth. And most interesting thing is that they comes with 5 IPv6 addresses in multiple locations. LowEndSpirit is pretty famous for their amazing service.

So I purchased one of these servers a week ago, and converted into a simple continuous integration server and trust me, it’s running just amazing. Here is what I did 🙂

1. I pointed one of my domains to this LowEndSpirit server (Lets call it LES Server) using cloudflare’s free IPv6 to IPv4 proxy,

2. Once the domain is working, I created one php file in my LES server. This php file is working as the webhook endpoint. Lets assume that this file url is so that we can refer to it in the rest of this article. The only thing this webhook.php file is doing is creating a file in the /tmp directory, for example /tmp/hook.txt

3. I created a ssh key using “ssh-keygen -t rsa” command in my LES server, and copied the content of the public key (~/.ssh/ generated by this command. Don’t use a passphrase when you create this key. Now I went to bitbucket/github and added this public key as deploy key (Here’s how to set it up in Bitbucket and in Github). This makes sure the readonly access of this key, that is very important from the security pov that you use a deployment key. Now in my LES server I checked out my repository. Lets consider that I checked out at /path/to/my/repo

I have also add the URL of this webhook php file to the bitbucket/github’s hook/webhook section. This makes sure that whenever I push code, bitbucket/github will make and HTTP POST call to this webhook php.

4. Now copy the content of your public key (~/.ssh/ in your LES server, and add it in your Remote Project server’s authorized keys file (~/.ssh/authorized_keys). If you are concerned about security then you may also chroot, but that’s not essential. Once this LES server’s public key is added in your Remote Server’s authorized key section, the connection will be smooth.

5. I wrote a simple bash script which checks if there is any file named hook.txt in /tmp directory in my LES server. If it is found then it ‘git pull’ the repository and perform an rsync which updates my project code folder in the remote server, and then remove this /tmp/hook.txt . I saved this shell script to /path/to/shell/ . Here is the content of the bash script. Don’t forget to give it executable permission by “chmod +x /path/to/shell/” command

[sourcecode language=”shell”]
if [ -f "/tmp/hook.txt" ]; then
rm -f /tmp/hook.txt
cd /path/to/my/repo
git pull
rsync -rltuvh /path/to/my/repo/ [email protected]:/remote/path/of/the/repo/
echo "Done"

6. Now the final step is registering a cronjob. You can register a cronjob by invoking “crontab -e” command in your terminal window. So I went ahead and registered this cron job in my LES server.

[sourcecode language=”shell”]
*/5 * * * * /path/to/shell/ > /tmp/cron.log

It runs every five minutes and if the /tmp/hook.txt is found it update the local repository by “git pull” and rsync only the updated files. My project folder in remote server is instantly updated 🙂

The server and service is running just great. Honestly, that’s a huge service running by a $4/year server 🙂

By the way this is more of a Continuous Deployment in true sense, just fyi!


    1. Yeah, I remember that many people were wondering what others do with these low end boxes. And a majority of replies confirmed that those are used as DNS server. Some people also use it as VPN gateways and CDN servers. Pretty interesting, eh?

    1. Continuous Integration is the process of integrating your code (whether bleeding edge/hot fix/master branch) to the test/development/production server. Now, whether it needs to pass the tests or not is more of a “choice” and that doesn’t put “continuous integration” in question. As long as your code is integrated, it’s continuous integration in simple. Of course, you may (and you should) want that test cases will pass to avoid regression or from introducing new bugs. But there are specific tools for performing those tasks, like Hudson/Jenkins/Xing/Phing/Travis/Capistrano and many more.

      This is also a form of continuos integration, simplest at it’s best 🙂

  1. Yeah, it’s interesting that people are using it as a Content Deliver Network. Is the 100mbit link speed for the entire node or each individual Virtual Server? It’s usually listed for the entire node so 12.2 MB/sec for a bunch of VPS’s isn’t the best for a CDN but I guess at this price point it’s not really a high traffic CDN.

Leave a comment

Your email address will not be published. Required fields are marked *