Let’s face it, if you’ve used Heroku, you love their easy deploy process - I know I do! But if you try to host a hobby project that requires access to the local filesystem, or in my case I want the site to be hosted on the naked domain without having to use DNSimple or another provider that has ALIAS records, then Heroku quickly becomes a problem.
So I’ve created this easy breazy process to git deploy your website
-
On the server, create a new repository in /var/git/ as the “code vault”:
git init --bare /var/git/chrisjones.git
-
Create a new post-deploy hook file named post-update
cd /var/git/chrisjones.git/hooks
cp post-update.sample post-update
-
Fill the file with this code for my Jekyll blog:
#!/bin/sh echo echo "**** Pulling changes into Live [Production's post-update hook]" echo cd /srv/chrisjones.dev || exit unset GIT_DIR git pull production master echo echo "bundle install" echo ~/.rbenv/shims/bundle install echo echo "Compiling assets..." echo JEKYLL_ENV=production ~/.rbenv/shims/bundle exec jekyll build exec git-update-server-info
-
Now create the web directory
mkdir /srv/chrisjones.dev
-
Setup directory to receive code:
git init
git remote add production /var/git/chrisjones.git
-
Now on the local development machine add the repository to your git config:
git remote add production webserver:/var/git/chrisjones.git
-
Now simply deploy!
git push production master
Whenever you have an update, or I want to create a new post, I simply commit the code and deploy to production. Boom!
Tags: devops