~corvus/hb9hox.radio

553c20ab1c0166c1942b10f078f803d8911a608d — Christian HB9HOX 6 months ago 9756608
Containerized preview
3 files changed, 18 insertions(+), 24 deletions(-)

M .gitignore
A Dockerfile
M Makefile
M .gitignore => .gitignore +2 -1
@@ 10,5 10,6 @@ hugo.exe
hugo.darwin
hugo.linux

# Temporary lock file while building
# Temporary build files
/.buildlog
/.hugo_build.lock

A Dockerfile => Dockerfile +5 -0
@@ 0,0 1,5 @@
FROM klakegg/hugo:ext-asciidoctor

RUN gem install --no-document concurrent-ruby tilt

COPY scripts/asciidoctor /usr/local/bin

M Makefile => Makefile +11 -23
@@ 1,34 1,22 @@
MAKEFLAGS += --warn-undefined-variables
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := jekyll-serve
.DEFAULT_GOAL := server
.DELETE_ON_ERROR:
.SUFFIXES:

DOCKER_IMG  ?= corvus-ch/hb9hox.radio
DOCKER_CMD  ?= docker
DOCKER_ARGS ?= run --rm --user="$$(id -u)" --volume="$${PWD}:/srv/jekyll" --workdir=/srv/jekyll --env JEKYLL_ENV
PODMAN_CMD   ?= podman
PODMAN_ARGS  ?= run --rm -it --volume="$${PWD}:/src" -p 1313:1313
PODMAN_LABEL ?= $(shell basename $(dir $(realpath $(firstword $(MAKEFILE_LIST)))))

JEKYLL_ARGS ?=
.PHONY: server
server: .buildlog
	$(PODMAN_CMD) $(PODMAN_ARGS) $$(tail -n 1 $<) server

.PHONY: jekyll-serve
jekyll-serve: image
	$(DOCKER_CMD) $(DOCKER_ARGS) -p 4000:4000 -p 35729:35729 $(DOCKER_IMG) jekyll serve --host 0.0.0.0 --livereload $(JEKYLL_ARGS)

.PHONY: jekyll-%
jekyll-%: image
	$(DOCKER_CMD) $(DOCKER_ARGS) $(DOCKER_IMG) jekyll $* $(JEKYLL_ARGS)

.PHONY: update
update: Gemfile.lock clean image

.PHONY: image
image: Dockerfile Gemfile.lock
	$(DOCKER_CMD) build -t $(DOCKER_IMG) .

Gemfile.lock: Gemfile
	$(DOCKER_CMD) $(DOCKER_ARGS) jekyll/jekyll:4 bundle lock
.buildlog: Dockerfile
	$(PODMAN_CMD) build --label $(PODMAN_LABEL) . | tee $@

.PHONY: clean
clean:
	($(DOCKER_CMD) images | grep $(DOCKER_IMG)) && $(DOCKER_CMD) rmi $(DOCKER_IMG) || true
	$(PODMAN_CMD) system prune --force --filter label=$(PODMAN_LABEL)
	rm -rf public/* .buildlog