05 Dec 2014
GitHub pages and Docker
You need to install Ruby, Jekyll and a lot of Ruby gems to test your blog on your machine. With Docker, you can eliminate these installations and run Jekyll in a fancy Docker container. I think, this method is far more simple (and elegant) than the manual way to install all the gems Jekyll needs.
Requirements:
- a Linux machine with Docker installed,
- a Docker image containing all Ruby gems installed,
fig
installed on your host.
I found a great Docker image but I needed some more gems to be installed, so I extended it with some instructions:
The base image creates a mount point at /src
, so I can mount the
source code of my site into the container. Accoring to the original
author, we can start the container with the following command:
It’s a good feature, but we can go deeper and use fig to make it more comfortable.
Docker’s fig can describe your containers in a YAML file, so you don’t have to specify their parameters on every run. My fig.yml looks like this:
It says, build a Docker image from my Dockerfile, mount the current directory as /src into the container and create a port binding between the host and the container.
You have to bootstrap it first:
Now, you can start your own Jekyll server with the following command:
And that’s all :)
References
Till next time,
Tibor Benke
at 23:00