Running Jekyll with minimal-mistakes theme inside docker

less than 1 minute read

this blog is built using:

1. clone the minimal-mistakes repo
git clone https://github.com/mmistakes/minimal-mistakes.git
2. create a Dockerfile to build a base container to generate a Gemfile.lock
FROM ruby:3.0

WORKDIR /srv/jekyll

VOLUME /srv/jekyll
3. build the container
docker build -t blog .

docker build

4. generate the Gemfile.lock
docker run --volume="$PWD:/srv/jekyll" -it blog bundle install 

docker Gemlock

5. modify the above Dockerfile to incorporate the lock file
FROM ruby:3.0

RUN bundle config --global frozen 1

WORKDIR /srv/jekyll

COPY Gemfile Gemfile.lock minimal-mistakes-jekyll.gemspec ./

RUN bundle install

VOLUME /srv/jekyll
6. build the container
docker build -t blog .

docker build

7. create a docker-compose.yml file
version: "3.0"

services:
  dev:
    image: blog
    command: ["jekyll", "serve", "--incremental", "--livereload"]
    ports:
      - "4000:4000"
    volumes:
      - $PWD:/srv/jekyll
8. add the port and host to _config.yml
port: 4000
host: "0.0.0.0"
9. Fire it up
docker-compose up

docker compose

ISSUE with Ruby 3:

I recenty ran into this error when starting jekyll:

cannot load such file -- webrick

Following the guidance in this bug

I added the webrick to the gemspec like this in Gemfile before generting the Gemlock:

source "https://rubygems.org"
group :jekyll_plugins do
  gem "webrick"
  gem "jekyll-archives"
end
gemspec

Updated: