Skip to content

Commit 9ce40d9

Browse files
authored
Add support for Apple container for building and running website locally (#1232)
1 parent 7fa19bb commit 9ce40d9

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

Makefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ npm install
4848
npm run prettify
4949
```
5050

51+
### Running with Apple Container
52+
53+
On macOS 26 and later, you can use the [Apple Container](https://github.com/apple/container) tool to host and run the website.
54+
55+
First install and run `container`:
56+
57+
```shell
58+
brew install container
59+
brew services start container
60+
```
61+
62+
Then build and run the site:
63+
64+
```shell
65+
make build
66+
make website
67+
```
68+
69+
The website will be available at `http://localhost:4000`
70+
5171
### Running in Docker
5272

5373
First build the site with Docker Compose:

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ url: https://swift.org
22
title: Swift.org
33
description: "Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns."
44
timezone: America/Lower_Princes
5-
exclude: ["README.md", "config.ru", "Gemfile", "Gemfile.lock", "Procfile", "vendor", "get-started/storybook"]
5+
exclude: ["README.md", "config.ru", "Gemfile", "Gemfile.lock", "Procfile", "vendor", "get-started/storybook", "Makefile"]
66
safe: false
77
future: true
88

0 commit comments

Comments
 (0)