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.
The basic flow for each of these projects (I’m going to use Docker Cloud as a reference implementation):
- Store data in Git (I use Bitbucket for my private projects).
- Create an SSH key to be used in deployments and attach to the Bitbucket account.
Create a new Stack in Docker Cloud. A stack is similar to a Docker Compose file:
my-stack: environment: - GIT_REPOfirstname.lastname@example.org:myname/myrepo - SSH_KEY=SOME_SSH_KEY image: thoom/lanyon:latest
Create a Docker Cloud Redeploy trigger.
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:
- It pulls down the Git repository using the environment variables defined earlier.
- In runs Bundler (which Jekyll expects as part of its installation) excluding any development gems.
- Executes the
jekyll buildcommand. This command creates a
- Nginx starts up and serves up the contents of the
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.