diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..43155b129 --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +# Makefile for managing the Swift website with container + +# Define the container runtime. Default to `container`. +# Can be overridden from the command line, e.g., `make CONTAINER=docker website` +CONTAINER ?= container + +.PHONY: help build run-build website stop clean + +help: + @echo "Usage:" + @echo " make build Build the swift-website-builder container image" + @echo " make run-build Build the Jekyll website" + @echo " make website Run the Jekyll development server" + @echo " make stop Stop the running website container" + @echo " make clean Stop the container and remove the build output" + @echo "" + @echo "To use a different container runtime (e.g. podman), run:" + @echo " make CONTAINER=podman build" + +# Build the primary container image +build: + $(CONTAINER) build --tag swift-website-builder --file Dockerfile . + +# Run a one-off Jekyll build +run-build: + @mkdir -p ./.output + $(CONTAINER) run --rm \ + -v "$(CURDIR)":/srv/jekyll \ + -v "$(CURDIR)/.output":/output \ + swift-website-builder \ + /bin/bash -cl "bundle check && bundle exec jekyll build --source /srv/jekyll --destination /output" + +# Run the development web server +website: + @mkdir -p ./.output + $(CONTAINER) run -d --rm --name swift-website \ + -p 4000:4000 \ + -v "$(CURDIR)":/srv/jekyll \ + -v "$(CURDIR)/.output":/output \ + swift-website-builder \ + /bin/bash -cl "bundle check && bundle exec jekyll serve --source /srv/jekyll --destination /output --host 0.0.0.0 --watch" + @echo "Website is running at http://localhost:4000" + +# Stop the development server +stop: + $(CONTAINER) stop swift-website + +# Clean up build artifacts +clean: stop + @echo "Removing .output directory..." + @rm -rf ./.output diff --git a/README.md b/README.md index e35035784..a2eba2c53 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,26 @@ npm install npm run prettify ``` +### Running with Apple Container + +On macOS 26 and later, you can use the [Apple Container](https://github.com/apple/container) tool to host and run the website. + +First install and run `container`: + +```shell +brew install container +brew services start container +``` + +Then build and run the site: + +```shell +make build +make website +``` + +The website will be available at `http://localhost:4000` + ### Running in Docker First build the site with Docker Compose: diff --git a/_config.yml b/_config.yml index 228a564b2..82f5ba371 100644 --- a/_config.yml +++ b/_config.yml @@ -2,7 +2,7 @@ url: https://swift.org title: Swift.org description: "Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns." timezone: America/Lower_Princes -exclude: ["README.md", "config.ru", "Gemfile", "Gemfile.lock", "Procfile", "vendor", "get-started/storybook"] +exclude: ["README.md", "config.ru", "Gemfile", "Gemfile.lock", "Procfile", "vendor", "get-started/storybook", "Makefile"] safe: false future: true