Lanyon - Jekyll's Docker Friend

Feb 13, 2017   #jekyll  #lanyon  #docker  #deployment 

I finally made the move to migrate this site away from Tumblr. I originally used Tumblr because it was a simple alternative to the heavier blogging sites/frameworks like Blogspot and Wordpress. I tend to enjoy simplicity when it comes to my personal projects, leaning on Sinatra for Ruby-based projects and Silex or Slim for PHP projects.

While I was researching alternative blogging platforms, I found Jekyll. It’s a different type of blogging platform, where you build your posts as individual HTML/Markdown files and use the Ruby-based application to build static files that can then be hosted on a variety of platforms. So instead of having a dynamically-built website, you build your static blog site before deployment.

I was looking at the different deployment options available, and sadly my preferred option was missing: Docker. Github Pages and S3 deployments were very interesting, but as I have a Docker-based deployment using Docker Cloud, I didn’t want to spread managing my deployments to yet another provider. Plus, I have a personal blog that I want to also look at migrating away from Tumblr at some point and Github Pages only allow one per account.

While I have some custom private Docker images hosted on Docker Hub, I like to create and use reusable Docker images whenever possible. I’ve done this in the past with Summit, which I use to host a few smaller Ruby projects with basic dependencies. I use Ngnix-PHP-FPM similarly for my PHP projects. In both cases, I use environment variables to pass in Git repository URLs and credentials. I built Lanyon to follow a similar flow for Jekyll-based Git repositories.

Deployment flow

The basic flow for each of these projects (I’m going to use Docker Cloud as a reference implementation):

  1. Store data in Git (I use Bitbucket for my private projects).
  2. Create an SSH key to be used in deployments and attach to the Bitbucket account.
  3. Create a new Stack in Docker Cloud. A stack is similar to a Docker Compose file:

      image: thoom/lanyon:latest
  4. Create a Docker Cloud Redeploy trigger.

  5. Add the trigger URL as a POST-Commit hook.

How Lanyon works

Basically Lanyon is an Nginx server image, but there is a little bit of magic that happens when the Docker image is first created:

  1. It pulls down the Git repository using the environment variables defined earlier.
  2. In runs Bundler (which Jekyll expects as part of its installation) excluding any development gems.
  3. Executes the jekyll build command. This command creates a _site directory.
  4. Nginx starts up and serves up the contents of the _site directory.

Each subsequent restart just starts Nginx. To rebuild the site, you have to redeploy the Docker container.


The point of this project is to make it easy to use Docker to deploy your Jekyll-based blogs. It’s an early iteration as I’ve just moved my blog to Jekyll, but since I’m actively using Lanyon, it will continue to be updated and maintained.