Container image: releases only, a token by default, lean layers; every action pinned
The image is published to GHCR as the release's version when a release dispatches docker.yml, and never as latest or per commit. Pushes and pull requests that touch it build it and try headless (with and without a token) and browser mode, without publishing. The image: node:24-slim pinned by digest (the major CI tests on), npm ci from the lockfile in its own layer, only src, site, scripts and the harness copied in (an allow-list .dockerignore), root-owned and run as node, /saves ready for --save-dir. The entrypoint runs the servers with node directly and, with no SOT_MCP_TOKEN, makes a token for the run and prints it (MCP_NO_TOKEN=1 to opt out); the docs publish ports to 127.0.0.1 and explain --allow-host. Labels, SBOM and provenance on push. Every GitHub Action in every workflow is pinned to a commit SHA with its version, and Dependabot keeps the actions, the image's base and the npm tools current. tests/docker.test.js guards all of it. The ADR and the github-pages skill say the image is a tool: GHCR only, never Pages.
This commit is contained in:
parent
9c8cda44c1
commit
98735eb769
16 changed files with 367 additions and 110 deletions
4
.github/workflows/auto-release.yml
vendored
4
.github/workflows/auto-release.yml
vendored
|
|
@ -25,10 +25,10 @@ jobs:
|
|||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-node@v7
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
|
|
|
|||
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
|
|
@ -26,8 +26,8 @@ jobs:
|
|||
matrix:
|
||||
part: [1, 2, 3, 4]
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
|
|
@ -38,8 +38,8 @@ jobs:
|
|||
name: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
|
|
@ -61,8 +61,8 @@ jobs:
|
|||
translations:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
|
|
|
|||
4
.github/workflows/claude.yml
vendored
4
.github/workflows/claude.yml
vendored
|
|
@ -27,9 +27,9 @@ jobs:
|
|||
id-token: write
|
||||
actions: read
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- uses: anthropics/claude-code-action@v1
|
||||
- uses: anthropics/claude-code-action@c0949c50a78c1ec8ce2647db36629b870e715d0c # v1.0.268
|
||||
with:
|
||||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
||||
|
|
|
|||
174
.github/workflows/docker.yml
vendored
174
.github/workflows/docker.yml
vendored
|
|
@ -1,72 +1,164 @@
|
|||
name: Build and push Docker image
|
||||
name: Container image
|
||||
|
||||
# Every push to main publishes :latest and :<sha>. A release publishes :<version>
|
||||
# built from its tag: auto-release.yml dispatches this workflow alongside the Pages
|
||||
# deploy, because releases created with the workflow token do not fire the
|
||||
# "released" event. Hand-published releases fire it directly.
|
||||
# Publishes ghcr.io/<owner>/<repo>:<version> for releases, and nothing else: auto-release.yml dispatches this workflow
|
||||
# with the new tag (pre-releases too). There is no :latest and no image per commit. Pushes and pull requests that change
|
||||
# what goes into the image only build it and try both modes; they never publish. The image packages the MCP server and
|
||||
# the development server; the game itself is hosted on GitHub Pages only (docs/adr/0001-github-pages-only.md).
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
release:
|
||||
types: [released, prereleased]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: Existing release tag to build (e.g. v2.10.0); empty builds main
|
||||
required: false
|
||||
description: Release tag to build and publish (e.g. v2.10.1)
|
||||
required: true
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- docker/**
|
||||
- .dockerignore
|
||||
- package.json
|
||||
- package-lock.json
|
||||
- scripts/**
|
||||
- tests/harness.js
|
||||
- .github/workflows/docker.yml
|
||||
pull_request:
|
||||
paths:
|
||||
- docker/**
|
||||
- .dockerignore
|
||||
- package.json
|
||||
- package-lock.json
|
||||
- scripts/**
|
||||
- tests/harness.js
|
||||
- .github/workflows/docker.yml
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
concurrency:
|
||||
group: docker-${{ github.event_name }}-${{ inputs.tag || github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name != 'workflow_dispatch' }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ github.event.release.tag_name || inputs.tag }}
|
||||
ref: ${{ inputs.tag || '' }}
|
||||
persist-credentials: false
|
||||
|
||||
- name: Work out the image tags
|
||||
id: tags
|
||||
env:
|
||||
TAG: ${{ github.event.release.tag_name || inputs.tag }}
|
||||
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
|
||||
- name: Build for this runner
|
||||
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
||||
with:
|
||||
context: .
|
||||
file: docker/Dockerfile
|
||||
platforms: linux/amd64
|
||||
load: true
|
||||
push: false
|
||||
tags: sot:test
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Try both modes
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# The image is named after this repository (ghcr.io/<owner>/<repo>, lowercased).
|
||||
image=ghcr.io/${GITHUB_REPOSITORY,,}
|
||||
if [ -n "$TAG" ]; then
|
||||
want="v$(jq -r .version package.json)"
|
||||
if [ "$TAG" != "$want" ]; then
|
||||
echo "::error::Release tag $TAG does not match package.json version ($want)"
|
||||
exit 1
|
||||
fi
|
||||
echo "tags=$image:${TAG#v}" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "tags=$image:latest,$image:$GITHUB_SHA" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
init='{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"ci","version":"1"}}}'
|
||||
mcp() { curl -sS -o /tmp/out -w '%{http_code}' -X POST http://127.0.0.1:7777/mcp \
|
||||
-H 'content-type: application/json' -H 'accept: application/json, text/event-stream' "$@" -d "$init"; }
|
||||
until_up() { for i in $(seq 1 60); do curl -s -o /dev/null "$1" && return 0; sleep 1; done; docker logs "$2"; exit 1; }
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
# Headless, with a token: refused without it, answered with it.
|
||||
docker run -d --name h -p 127.0.0.1:7777:7777 -e MCP_MODE=headless -e SOT_MCP_TOKEN=ci-token sot:test
|
||||
until_up http://127.0.0.1:7777/ h
|
||||
test "$(mcp)" = 401
|
||||
test "$(mcp -H 'authorization: Bearer ci-token')" = 200
|
||||
grep -q serverInfo /tmp/out
|
||||
docker rm -f h
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
# No token given: the container makes one, says so, and wants it.
|
||||
docker run -d --name t -p 127.0.0.1:7777:7777 -e MCP_MODE=headless sot:test
|
||||
until_up http://127.0.0.1:7777/ t
|
||||
test "$(mcp)" = 401
|
||||
tok=$(docker logs t 2>&1 | sed -n "s/.*this run's token is //p" | head -1)
|
||||
test -n "$tok"
|
||||
test "$(mcp -H "authorization: Bearer $tok")" = 200
|
||||
docker rm -f t
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
# Browser mode: the development page and the MCP server.
|
||||
docker run -d --name b -p 127.0.0.1:8080:8080 -p 127.0.0.1:7777:7777 -e SOT_MCP_TOKEN=ci-token sot:test
|
||||
until_up http://127.0.0.1:8080/ b
|
||||
test "$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8080/)" = 200
|
||||
until_up http://127.0.0.1:7777/ b
|
||||
test "$(mcp -H 'authorization: Bearer ci-token')" = 200
|
||||
docker rm -f b
|
||||
|
||||
# The server runs as node, not root.
|
||||
test "$(docker run --rm --entrypoint id sot:test -u)" != 0
|
||||
|
||||
publish:
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Check the tag
|
||||
env:
|
||||
TAG: ${{ inputs.tag }}
|
||||
run: |
|
||||
[[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]] || { echo "::error::Not a release tag: $TAG"; exit 1; }
|
||||
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ inputs.tag }}
|
||||
persist-credentials: false
|
||||
|
||||
- name: Work out the image name and version
|
||||
id: meta
|
||||
env:
|
||||
TAG: ${{ inputs.tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
want="v$(jq -r .version package.json)"
|
||||
if [ "$TAG" != "$want" ]; then echo "::error::Release tag $TAG does not match package.json ($want)"; exit 1; fi
|
||||
# Named after this repository (ghcr.io/<owner>/<repo>, lowercased), so forks publish their own.
|
||||
echo "image=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
|
||||
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
|
||||
echo "revision=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
||||
echo "created=$(git log -1 --format=%cI)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
|
||||
|
||||
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
|
||||
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
- name: Build and push the release's version
|
||||
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
||||
with:
|
||||
context: .
|
||||
file: docker/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.tags.outputs.tags }}
|
||||
tags: ${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.version }}
|
||||
labels: |
|
||||
org.opencontainers.image.title=Series of Tubes MCP server
|
||||
org.opencontainers.image.description=The Series of Tubes MCP server and development server, so an AI client can play the game.
|
||||
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
||||
org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/${{ inputs.tag }}/docs/MCP.md
|
||||
org.opencontainers.image.version=${{ steps.meta.outputs.version }}
|
||||
org.opencontainers.image.revision=${{ steps.meta.outputs.revision }}
|
||||
org.opencontainers.image.created=${{ steps.meta.outputs.created }}
|
||||
org.opencontainers.image.licenses=MIT
|
||||
provenance: mode=max
|
||||
sbom: true
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
|
|
|||
2
.github/workflows/perf-comment.yml
vendored
2
.github/workflows/perf-comment.yml
vendored
|
|
@ -17,7 +17,7 @@ jobs:
|
|||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: perf
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
|
|
|
|||
6
.github/workflows/perf.yml
vendored
6
.github/workflows/perf.yml
vendored
|
|
@ -22,8 +22,8 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 40
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
|
|
@ -48,7 +48,7 @@ jobs:
|
|||
env:
|
||||
PR: ${{ github.event.pull_request.number }}
|
||||
run: echo "$PR" > pr-number.txt
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
name: perf
|
||||
|
|
|
|||
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
|
|
@ -42,10 +42,10 @@ jobs:
|
|||
ALLOW_OLDER: ${{ inputs.allow_older || false }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ env.TAG }}
|
||||
- uses: actions/setup-node@v7
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
|
|
@ -100,7 +100,7 @@ jobs:
|
|||
run: npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js $(ls tests/weekly-scenario.test.js tests/weekly-architect.test.js 2>/dev/null)
|
||||
- name: Build site
|
||||
run: VERSION="${TAG#v}" REQUIRE_NOTES=1 npm run build
|
||||
- uses: actions/upload-pages-artifact@v5
|
||||
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
|
||||
with:
|
||||
path: ./_site
|
||||
|
||||
|
|
@ -115,9 +115,7 @@ jobs:
|
|||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- id: deployment
|
||||
uses: actions/deploy-pages@v5
|
||||
|
||||
# Tell IndexNow (Bing, Yandex, Seznam, …) about the new version, only after
|
||||
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
|
||||
# the site is live.
|
||||
indexnow:
|
||||
needs: deploy
|
||||
|
|
|
|||
4
.github/workflows/weekly-puzzle.yml
vendored
4
.github/workflows/weekly-puzzle.yml
vendored
|
|
@ -38,10 +38,10 @@ jobs:
|
|||
GH_TOKEN: ${{ github.token }}
|
||||
KEY: ${{ inputs.key }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: main
|
||||
- uses: actions/setup-node@v7
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue