Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mikel-egana-aranguren/3534a8ab3f4daaadb953337d52e388a2 to your computer and use it in GitHub Desktop.
Save mikel-egana-aranguren/3534a8ab3f4daaadb953337d52e388a2 to your computer and use it in GitHub Desktop.
Docker for Jekyll
http://diegolavalle.com/code/2016/05/31/dr-jekyll-and-mr-docker.html?mkt_tok=eyJpIjoiWm1RMFkyRTRPVE01WlRabSIsInQiOiJZTnpqc2hOdEthcVI5QktGZG1QaUFBdmsyVGExR0J3dTFrNlkrWmkreDMwMGY1Nmt3Y0VxNHdmQVpXSFp5RGNVS1k0RGR2aFJ0XC9KcDN2WTdcL2NvdTJPTk1pZGJKVlwvKyszenlWUXhkaGdEYz0ifQ%3D%3D
Dr. Jekyll and Mr. Docker
May 31, 2016
I like using Jekyll to write my blog. But I am not a Ruby developer. So filling my Mac with tools and dependencies that I will only ultimately use for posting articles doesn’t seem right.
I am a developer though and so lately I became more and more familiar with Docker. Wouldn’t it be great to have a container that let us generate and preview our Jekyll site locally? Lucky for us someone has compiled a great image to do exactly that. Here it is:
https://hub.docker.com/r/starefossen/github-pages/
While well-documented, the steps to make my project self-contained turned out to be a little different. These are the contents of the Dockerfile:
FROM starefossen/github-pages:onbuild
And the docker-compose.yml file I created in my project root:
app:
build: .
ports:
- '4000:4000'
volumes:
- .:/usr/src/app
env_file: app.env
The token for GitHub pages can be generated at https://github.com/settings/tokens/new after sign in. Store it in app.env with format JEKYLL_GITHUB_TOKEN=###.
Before building the image for the first time make sure there’s no residual Gemfile.lock file from previous attempts. I had to delete mine.
After that it’s just a matter of typing docker-compose up which will start a local version of the site and watch for any changes on your source files. Yay!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment