Post

Jekyll Local Build

After moving away from GitHub, the automated build via GitHub Actions is gone. The site now needs to be built locally before pushing a release to Forgejo.

I want to keep using Docker for this. It runs in a defined environment and there are no Ruby version headaches or missing native dependencies depending on the machine. The same image I already use for previewing posts handles the build too.

Prerequisites

Docker needs to be installed and running. Under WSL, Docker Desktop with WSL integration enabled is the easiest way to get there.

After cloning the repository, initialize the Git submodule for the static assets:

1
git submodule update --init

Dev Server

For writing and previewing posts, I start the dev server from the repository root:

1
2
3
4
5
6
docker run -p 4000:4000 \
  -e GIT_CONFIG_COUNT=1 \
  -e GIT_CONFIG_KEY_0=safe.directory \
  -e GIT_CONFIG_VALUE_0=/site \
  -v ${PWD}:/site \
  ghcr.io/bretfisher/jekyll-serve

The site is available at http://localhost:4000. The server watches for file changes and rebuilds automatically.

The -e GIT_CONFIG_* flags are needed because Docker runs as a different user than the file owner in WSL. Without them, git refuses to read the repository and the posts-lastmod-hook.rb plugin cannot determine last-modified dates.

Add --drafts to also render posts from the _drafts/ folder.

Build

When the post is ready, I build the site to _site/:

1
2
3
4
5
6
7
docker run --rm \
  -e GIT_CONFIG_COUNT=1 \
  -e GIT_CONFIG_KEY_0=safe.directory \
  -e GIT_CONFIG_VALUE_0=/site \
  -v ${PWD}:/site \
  ghcr.io/bretfisher/jekyll-serve \
  bundle exec jekyll build

The output in _site/ is then packaged and uploaded as a release asset on Forgejo.

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