Introduction

  • I like jekyll. Because it is simple and reliable.
  • I want to use this cooler by using a docker.
  • There have been some attempts, but I wanted to set it up for my situation.
    • Use nginx-proxy
    • Use subdomains (e.g., dkdk.domain.com)
    • Do not use special ports (e.g., dkdk.domain.com:4000) without :4000
  • I have been successful in setting up the site as follows.

Setup nginx-proxy (Option)

  • If you have already setup, Take the next step
$ docker-compose.yml
version: '2'

services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
    restart: always

networks:
  default:
    external:
      name: nginx-proxy
$ docker-compose up -d

Setup Jekyll

Dockerfile

  • Write the Dockerfile as follows.
$ vim Dockerfile
FROM starefossen/ruby-node:2-6-alpine

ENV GITHUB_GEM_VERSION 192
ENV JSON_GEM_VERSION 1.8.6

RUN apk --update add --virtual build_deps \
      build-base ruby-dev libc-dev linux-headers \
      && gem install --verbose --no-document \
      json:${JSON_GEM_VERSION} \
      github-pages:${GITHUB_GEM_VERSION} \
      jekyll-github-metadata \
      minitest \
      && apk del build_deps \
      && apk add git \
      && mkdir -p /usr/src/app \
      && rm -rf /usr/lib/ruby/gems/*/cache/*.gem

WORKDIR /usr/src/app

EXPOSE 80
CMD jekyll serve -d /_site --watch --force_polling -H 0.0.0.0 -P 80
  • ref : https://hub.docker.com/r/starefossen/github-pages/dockerfile
  • Changed only the port. (4000 → 80)

Docker Build

docker build -t dkdk:jekyll .
  • -t : Name and optionally a tag in the name:tag format
  • I set it to dkdk: jekyll. Remember
  • Do not subtract points(.) at the end

Check New images

  • You can see dkdk: jekyll
docker images
REPOSITORY         TAG            IMAGE ID            CREATED             SIZE
dkdk               jekyll         17809d4394f4        35 seconds ago      211MB

Setyp theme

  • Copy theme directory for mount.
cp -R ./some_theme_dir ./theme

Create new docker-compose.yml

version: '2'

services:
  jekyll:
    image: 'dkdk:jekyll'
    restart: always
    hostname: 'dkdk.sciomagelab.com'
    container_name: jekyll
    volumes:
      - ./theme:/usr/src/app
    environment:
      JEKYLL_ENV: production
      VIRTUAL_HOST: 'dkdk.sciomagelab.com'
    expose:
      - 80

networks:
  default:
    external:
      name: nginx-proxy
  • image : dkdk:jekyll (Your image)

Run new docker

$ docker-compose up -d