Posts Deploy Jekyll in Docker
Post
Cancel

Deploy Jekyll in Docker

GitHub Pages is a fantastic hosting service for blogging, specially for software developers. GitHub Pages runs on Jekyll and I did not want to install Ruby and other dependencies on my Windows system. Consequently, docker was the answer.

On a PowerShell terminal

1
2
cd [path to the project directory]
docker run --rm --volume=$(pwd):/srv/jekyll -p 4000:4000 -it jekyll/jekyll:latest bash

On the container’s bash terminal we must type the following. It its important to chown because otherwise we will get permission errors.

1
2
3
4
5
6
chown jekyll:jekyll .
chown jekyll:jekyll -R /usr/gem
jekyll new .
bundle update
jekyll build
jekyll serve

The project now is hosted in http://localhost:4000/

It is convenient to create a permanent container to serve our project.The option —force_polling enable jekyll to watch for changes and automatically deploys them.

1
docker run --name myblog --volume=$(pwd):/srv/jekyll -p 4000:4000 -it jekyll/jekyll:latest jekyll serve --force_polling

Next time we just start up the container.

This post is licensed under CC BY 4.0 by the author.