Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down