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