|
| 1 | +# Makefile for managing the Swift website with container |
| 2 | + |
| 3 | +# Define the container runtime. Default to `container`. |
| 4 | +# Can be overridden from the command line, e.g., `make CONTAINER=docker website` |
| 5 | +CONTAINER ?= container |
| 6 | + |
| 7 | +.PHONY: help build run-build website stop clean |
| 8 | + |
| 9 | +help: |
| 10 | + @echo "Usage:" |
| 11 | + @echo " make build Build the swift-website-builder container image" |
| 12 | + @echo " make run-build Build the Jekyll website" |
| 13 | + @echo " make website Run the Jekyll development server" |
| 14 | + @echo " make stop Stop the running website container" |
| 15 | + @echo " make clean Stop the container and remove the build output" |
| 16 | + @echo "" |
| 17 | + @echo "To use a different container runtime (e.g. podman), run:" |
| 18 | + @echo " make CONTAINER=podman build" |
| 19 | + |
| 20 | +# Build the primary container image |
| 21 | +build: |
| 22 | + $(CONTAINER) build --tag swift-website-builder --file Dockerfile . |
| 23 | + |
| 24 | +# Run a one-off Jekyll build |
| 25 | +run-build: |
| 26 | + @mkdir -p ./.output |
| 27 | + $(CONTAINER) run --rm \ |
| 28 | + -v "$(CURDIR)":/srv/jekyll \ |
| 29 | + -v "$(CURDIR)/.output":/output \ |
| 30 | + swift-website-builder \ |
| 31 | + /bin/bash -cl "bundle check && bundle exec jekyll build --source /srv/jekyll --destination /output" |
| 32 | + |
| 33 | +# Run the development web server |
| 34 | +website: |
| 35 | + @mkdir -p ./.output |
| 36 | + $(CONTAINER) run -d --rm --name swift-website \ |
| 37 | + -p 4000:4000 \ |
| 38 | + -v "$(CURDIR)":/srv/jekyll \ |
| 39 | + -v "$(CURDIR)/.output":/output \ |
| 40 | + swift-website-builder \ |
| 41 | + /bin/bash -cl "bundle check && bundle exec jekyll serve --source /srv/jekyll --destination /output --host 0.0.0.0 --watch" |
| 42 | + @echo "Website is running at http://localhost:4000" |
| 43 | + |
| 44 | +# Stop the development server |
| 45 | +stop: |
| 46 | + $(CONTAINER) stop swift-website |
| 47 | + |
| 48 | +# Clean up build artifacts |
| 49 | +clean: stop |
| 50 | + @echo "Removing .output directory..." |
| 51 | + @rm -rf ./.output |
0 commit comments