Add V2 Forgejo workflow publishing study:v2 image
Pushes to v2 typecheck and test inside the Node 24 image via a new Dockerfile test stage, build and smoke-test the production image as a fresh non-root container, then publish :v2 and :v2-<sha>. Never touches V1's :latest. Document the image tags and Unraid 99:100 volume ownership. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d7e19db468
commit
3046e46d1c
4 changed files with 107 additions and 10 deletions
68
.forgejo/workflows/build-v2.yml
Normal file
68
.forgejo/workflows/build-v2.yml
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
name: Verify and publish V2 container
|
||||
|
||||
# Publishes ONLY the `v2` and `v2-<sha>` tags. It never touches `latest`, which V1's
|
||||
# workflow on `main` publishes and the current production container may track.
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- v2
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Resolve image names
|
||||
run: |
|
||||
IMAGE_PATH=$(echo "git.elijahkuntz.com/${{ gitea.actor }}/${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
|
||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-12)
|
||||
echo "IMAGE_PATH=$IMAGE_PATH" >> "$GITHUB_ENV"
|
||||
echo "IMAGE_SHA=$IMAGE_PATH:v2-$SHORT_SHA" >> "$GITHUB_ENV"
|
||||
echo "IMAGE_V2=$IMAGE_PATH:v2" >> "$GITHUB_ENV"
|
||||
|
||||
# Typecheck and tests run inside the Node 24 image the runtime uses, so the runner's
|
||||
# own Node version does not matter.
|
||||
- name: Typecheck and test
|
||||
run: docker build --target test -t "study-v2-test:${{ github.sha }}" .
|
||||
|
||||
- name: Build production image
|
||||
run: docker build -t "$IMAGE_SHA" .
|
||||
|
||||
- name: Smoke-test the production image
|
||||
run: |
|
||||
SMOKE="study-v2-smoke-$(openssl rand -hex 6)"
|
||||
cleanup() { docker rm -f "$SMOKE" > /dev/null 2>&1 || true; }
|
||||
trap cleanup EXIT
|
||||
docker run -d --name "$SMOKE" "$IMAGE_SHA"
|
||||
for attempt in $(seq 1 30); do
|
||||
STATUS=$(docker inspect --format='{{.State.Health.Status}}' "$SMOKE")
|
||||
if [ "$STATUS" = "healthy" ]; then break; fi
|
||||
if [ "$(docker inspect --format='{{.State.Running}}' "$SMOKE")" != "true" ]; then break; fi
|
||||
sleep 2
|
||||
done
|
||||
if [ "$(docker inspect --format='{{.State.Health.Status}}' "$SMOKE")" != "healthy" ]; then
|
||||
docker logs "$SMOKE"
|
||||
exit 1
|
||||
fi
|
||||
# Runs as the non-root node user, data volume writable, first-run setup code created.
|
||||
test "$(docker exec "$SMOKE" id -u)" != "0"
|
||||
docker exec "$SMOKE" test -s /data/setup-code.txt
|
||||
docker exec "$SMOKE" test -s /data/study.db
|
||||
# Web app served; fresh install reports setup needed; private API denied.
|
||||
docker exec "$SMOKE" node -e "fetch('http://127.0.0.1:3726/').then(async r => { const t = await r.text(); if (!r.ok || !t.includes('id=\"root\"')) process.exit(1) }).catch(() => process.exit(1))"
|
||||
docker exec "$SMOKE" node -e "fetch('http://127.0.0.1:3726/api/auth/status').then(async r => { const b = await r.json(); if (!r.ok || b.configured !== false || b.authenticated !== false) process.exit(1) }).catch(() => process.exit(1))"
|
||||
docker exec "$SMOKE" node -e "fetch('http://127.0.0.1:3726/api/classes').then(r => { if (r.status !== 401) process.exit(1) }).catch(() => process.exit(1))"
|
||||
docker logs "$SMOKE" 2>&1 | grep -vi 'setup code' | tail -n 20
|
||||
|
||||
- name: Log into registry
|
||||
run: |
|
||||
echo "${{ secrets.FORGEJO_PAT }}" | docker login git.elijahkuntz.com -u "${{ gitea.actor }}" --password-stdin
|
||||
|
||||
- name: Publish v2 tags
|
||||
run: |
|
||||
docker tag "$IMAGE_SHA" "$IMAGE_V2"
|
||||
docker push "$IMAGE_SHA"
|
||||
docker push "$IMAGE_V2"
|
||||
Loading…
Add table
Add a link
Reference in a new issue