Deploy a Ghost Blog in 10 Minutes with Giant Swarm

On By Kord Campbell in tech

Right before I started working fulltime at Giant Swarm, I authored a containerized deployment of Ghost which could be used by anyone to deploy a blog on our service. The first version of the deployment was fairly basic, so I spent a bit of time patching it up to include a few new features including:

  • Automated backups of all content to S3
  • Backup restore functionality on launch/update
  • A Varnish cache running in front of Ghost
  • nginx running in front of Ghost (forthcoming)
  • Mailgun account configuration
  • German privacy laws

That last one comes for free, because we’re a German infrastructure provider. ;)

I’m happy to announce this blog is now being being served from a slightly modified deployment of Ghost (link forthcoming) that Marian did using my deployment guide as a reference. The rest of this post will step through how you can start Ghost busting with a Giant Swarm account* in less than 10 minutes!

Here’s a quick demo of what you’ll get.

*If you haven’t gotten your GS account yet, be sure to sign up for the alpha test and mention on Gitter that you are running through this guide. We’ll get you sorted.

“Listen, do you smell something?” - Dr. Ray Stantz, Ghostbuster

Prerequisites Check

You need to have the following installed and running on your computer before you can launch your blog:

Optionally you need a Mailgun account and an AWS account for utlizing the S3 service for backups.

Checkout the Code

The code for the project is hosted on Github. Start by checking the code out:

git clone https://github.com/kordless/swarm-ghost.git

Now change to the directory:

cd swarm-ghost

Test Locally

To test the deployment locally, begin by editing the Makefile file and change the MYSQL_PASSWORD variable to be something secure:

MYSQL_PASSWORD=somethingsecurererering

Now start the MySQL container:

make docker-mysql-run

The container should exit to the background. Next, start the Ghost service:

make docker-run

You should get a bit of output and then a URL:

Ghost is running...
Your blog is now available on http://192.168.59.103:2368
Ctrl+C to shut down

Paste URL into your browser to test connecting directly to the Ghost service. If you want to test the cache container, you’ll need to open an new terminal window and then enter the following:

make docker-varnish-run

That should enable you to access the blog directly by IP (your mileage may vary):

http://192.168.59.103

You can hit ctrl-c to stop the Ghost and Varnish containers. To stop and delete the MySQL container, do the following:

docker stop mysql
docker rm mysql

Here’s a screencast of all that:

Deploy to Giant Swarm

Deploying to Giant Swarm is simple. Start by doing a swarm info to ensure you are logged in to Giant Swarm:

$ swarm info
Cluster status:      reachable
Swarm CLI version:   0.16.0 (your version may be newer)
Logged in as user:   kord
Current environment: kord/dev

Note: If you need assistance with logging in to Giant Swarm, please see this guide.

Now deploy the application to your account:

make swarm-up

That’s literally all you need to do. When your blog has finished launching, you’ll see a status message like this:

Visit http://ghost-kord.gigantic.io to see your blog and http://ghost-kord.gigantic.io/ghost/ to set it up.

Take the URL and plug it into your browser (using your username, of course):

http://ghost-kord.gigantic.io/ghost/

You should get to the setup screen:

A Note About Caching

The way the caching is setup on Varnish prevents updated posts from becoming immediately viewable. To work around this, I hacked the Varnish config to force a cache reload when you hold down shift-reload in your browser.

Further Reading

If you would like to enable backups and use of Mailgun for sending emails from your blog, be sure to head on over to the Swarming Ghost repository on Github.

Picture of Kord Campbell
Kord Campbell
Cowboy coder in the business of digital evangelism, cloud computing, cryptocurrencies, transparency & the coming age of trust. @utterio.

Let’s start your journey towards microservices

Contact us Now