Automated deployment of my Ghost blogs

Ghost is one my favorite blogging platforms. I am running this blog on Ghost, and my wife just asked me to host other blogs as well. I decided to automate the deployment of my blogs, so that I can upgrade, track, and add new blogs easily. Another project of mine is hipops, an infrastructure deployment tool that I have been working that makes my life easier (more on that later). I figured the automated deployment of my Ghost blogs is the best candidate for hipops. Here is how I did it...

Ghost setup

My goal was to setup a parent ghost repo that I can fork from to create all of the other repos. This way when I update the source repo, I can automatically pull in the changes from upstream to update all of them. Take a look at my base Ghost 0.5.0 repo, you will see a template folder that contains and bash scripts. Each of the blogs will also have script that will configure the specific blog configuration.

Creating Forks

There are a lot of good articles out there for creating multiple forks out of the one repo, but here is the summary of the steps.

  • Create an emtpy repo. e.g.
  • git clone
  • cd
  • git remote -v and you should see the origin is pointing to the base template
  • git remote rename origin upstream
  • git remote add origin
  • git push -u origin master
  • git remote -v and you should see upstream is pointing to the base repo, and origin is your blog.

Prepare Blog

Now that we have a base repo, let's add the content folder from Ghost. Let's also add the to the template folder, and make it executable.

usage() { echo "Usage: $0 [-f <flag>]" 1>&2; exit 1; }

while getopts ":f:" o; do  
  case "${o}" in
shift $((OPTIND-1))

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"  
cd $DIR/..

if [ "$flag" == "reset" ]; then  
  sed "s/" config.js > config.temp.js
  sed 's/mail: { transport: "SMTP", options: { service: "Mailgun", auth: { user: "", pass: "P@ssw0rd1" } } }/mail: {}/g' config.temp.js > config.temp2.js
  sed "s/" config.js > config.temp.js
  sed 's/mail: {}/mail: { transport: "SMTP", options: { service: "Mailgun", auth: { user: "", pass: "P@ssw0rd1" } } }/g' config.temp.js > config.temp2.js
mv config.temp2.js config.js  
rm config.temp.js  

Once you are done, add your files, commit, and push them to origin. Let's run template/ to make sure all of the all files are in sync. Let's do a test run of our blog by running:

  • sudo npm install --production
  • PORT=8083 NODE_ENV=production npm start
  • http://localhost:8083 should now have the new blog


hipops helps you with code deployment of your apps. It's in the early stages of development, and I will do a full post later about its capabilities. hipops uses go, ansible and docker to automate the process. Assuming you have ansible installed on your machine. Here are the steps to deploy the app...


(This will be a lot easier once I am done with the project.)

Let's get the latest version of hipops. go get Next, modify the config.json based on your blog setup. Under the apps section, you can remove and add your blogs, and under playbooks section modify the first play to have the correct apps. Also make sure you have the correct path for ssh keys on the server.


Once configured you can run hipops to orchestrate your machine. Assuming you have an empty Ubuntu 14.04 box with Docker installed in AWS.

go run hipops.go -h /Users/jams/ -c devops/ansible/scenarios/ubuntuOS.ghostBlogs/config.json -p devops/ansible/playbooks/ -k /Users/jams/.ssh/myawskey.pem

This will deploy your blogs and run them using Docker.

Updating the blogs

If you have a new version of Ghost that you would like to deploy. Here is how you can do it in 4 steps manually, or by adding them to a Jenkins job to do it automatically.

  • Login to AWS, and push the ghost.db changes from your production to your repo.
  • Update and push the base template changes.
  • run template/
  • re-run the hipops command to update the changes.
  • Done. Now all of your blogs have been updated to the latest changes.
comments powered by Disqus