ci: push amd64 images to the in-cluster Forgejo registry #63

Merged
sirius merged 2 commits from wt/ci-in-cluster-registry into master 2026-11-17 20:10:37 +00:00
Showing only changes of commit 005d271175 - Show all commits

ci: push amd64 images to the in-cluster Forgejo registry

The build has been red since 2026-11-14 (runs 1342+). Every failure is the
registry login step:

  Error response from daemon: Get "http://127.0.0.1:3000/v2/": dial tcp
  127.0.0.1:3000: connect: connection refused

Forgejo moved off the Pi's docker into k8s, so PUSH_REGISTRY=127.0.0.1:3000
was the job pod's own loopback. Point it at the in-cluster service
forgejo.forgejo.svc.cluster.local:3000 (whitelisted insecure on the runner).

Also:
- runs-on amd64 instead of docker: label docker only exists on the arm64 Pi
  runner, whose images the amd64 cluster cannot run.
- drop the job-level permissions block; Forgejo ignores it and flags it with a
  pre-execution warning, which was being read as the cause of the failures.
- drop the compose deploy step: it ran docker compose against the dind daemon,
  redeploying nothing. Deploys are pinned tags in homek8s apps/base/osint; the
  summary now prints the tag to pin.
- tag images amd64-<sha12> (one canonical tag, no :latest drift).
tui-design 2026-11-17 15:04:00 -05:00

View file

@ -1,21 +1,28 @@
# Build changed OSINT images, publish to the Forgejo container registry, then
# redeploy on the Pi runner (docker.sock mounted).
# Build changed OSINT images and publish them to the Forgejo container
# registry. Deployment is NOT done here: the cluster (homek8s, namespace
# `osint`) runs amd64 images pinned by tag in apps/base/osint/*.yaml, so the
# final step prints the tag to pin and a human opens that manifest PR.
#
# Unchanged images are skipped. Dockerfile.pg / osint-dashboard-pg is NOT
# rebuilt or pulled on a normal merge — Postgres stays up. Rebuild it only
# when Dockerfile.pg changes, or via workflow_dispatch rebuild_pg.
# rebuilt on a normal merge — Postgres stays up. Rebuild it only when
# Dockerfile.pg changes, or via workflow_dispatch rebuild_pg.
#
# Registry endpoints
# CI push host: forgejo.forgejo.svc.cluster.local:3000 — plain HTTP
# ClusterIP, whitelisted by --insecure-registry on the amd64
# runner's dind daemon. 127.0.0.1:3000 stopped working when
# Forgejo moved into k8s: inside an in-cluster job pod, loopback
# is the pod itself, so login died with "connection refused".
# Public pull: forgejo.siriusdevops.com (HTTPS via Cloudflare; kubelet pulls
# from here). Do NOT push here — Cloudflare 413s layers ≳100MB.
#
# Public pull host: forgejo.siriusdevops.com (NOT ghcr.io)
# CI push host: 127.0.0.1:3000 — Cloudflare 413s layers ≳100MB on the public
# hostname, even from the Pi (hairpins out through the tunnel).
# Images (public names):
# forgejo.siriusdevops.com/sirius/osint-dashboard
# forgejo.siriusdevops.com/sirius/osint-dashboard-pg
# forgejo.siriusdevops.com/sirius/osint-news-scraper
# forgejo.siriusdevops.com/sirius/osint-news-summarizer
# forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-<sha12>
# forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-<sha12>
# forgejo.siriusdevops.com/sirius/osint-news-scraper:amd64-<sha12>
# forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-<sha12>
#
# Optional repo variable FORGEJO_REGISTRY overrides the *public* pull host.
# Deploy still uses the local docker socket on the runner host (rpi).
name: build-and-deploy
@ -35,17 +42,19 @@ on:
env:
PUBLIC_REGISTRY: ${{ vars.FORGEJO_REGISTRY || 'forgejo.siriusdevops.com' }}
PUSH_REGISTRY: 127.0.0.1:3000
PUSH_REGISTRY: forgejo.forgejo.svc.cluster.local:3000
OWNER: sirius
# Keep compose project/volumes stable on the Pi
COMPOSE_PROJECT_NAME: osint-dashboard
jobs:
build-push-deploy:
runs-on: docker
permissions:
contents: read
packages: write
build-push:
# `amd64` only exists on siriussec-amd64, which is also the node the
# workloads run on — so the images are built on the architecture they are
# pulled to. `runs-on: docker` matched the Pi's arm64 runner, which
# produced images the amd64 cluster could never run.
# No job-level `permissions:` block: Forgejo ignores it (it emits a
# pre-execution warning) and the push authenticates with the FORGEJO_TOKEN
# user PAT instead, because the package registry rejects the Actions token.
runs-on: amd64
steps:
- name: Checkout
uses: https://code.forgejo.org/actions/checkout@v4
@ -60,7 +69,6 @@ jobs:
SCRAPER=0
SUM=0
PG=0
COMPOSE=0
mark() {
case "$1" in
@ -72,8 +80,6 @@ jobs:
SCRAPER=1 ;;
news/summerizer/*)
SUM=1 ;;
docker-compose.yml|scripts/compose-reup.sh)
COMPOSE=1 ;;
esac
}
@ -108,9 +114,8 @@ jobs:
echo "scraper=$SCRAPER"
echo "summarizer=$SUM"
echo "pg=$PG"
echo "compose=$COMPOSE"
} >> "$GITHUB_OUTPUT"
echo "plan app=$APP scraper=$SCRAPER summarizer=$SUM pg=$PG compose=$COMPOSE"
echo "plan app=$APP scraper=$SCRAPER summarizer=$SUM pg=$PG"
- name: Image refs
id: img
@ -120,10 +125,11 @@ jobs:
PUB="${PUBLIC_REGISTRY}"
OWN="${OWNER}"
SHA="${GITHUB_SHA::12}"
TAG="amd64-${SHA}"
{
echo "reg=$PUSH"
echo "pub=$PUB"
echo "sha=$SHA"
echo "tag=$TAG"
echo "app=$PUSH/$OWN/osint-dashboard"
echo "pg=$PUSH/$OWN/osint-dashboard-pg"
echo "scraper=$PUSH/$OWN/osint-news-scraper"
@ -131,7 +137,7 @@ jobs:
} >> "$GITHUB_OUTPUT"
echo "Push registry: $PUSH"
echo "Public pull: $PUB"
echo "SHA tag: $SHA"
echo "Image tag: $TAG"
- name: Login to Forgejo registry
if: steps.plan.outputs.app == '1' || steps.plan.outputs.scraper == '1' || steps.plan.outputs.summarizer == '1' || steps.plan.outputs.pg == '1'
@ -150,94 +156,43 @@ jobs:
if: steps.plan.outputs.app == '1'
run: |
set -ex
APP="${{ steps.img.outputs.app }}"
SHA="${{ steps.img.outputs.sha }}"
docker build -f Dockerfile -t "${APP}:latest" -t "${APP}:${SHA}" \
-t "localhost/osint-dashboard:latest" .
docker push "${APP}:latest"
docker push "${APP}:${SHA}"
IMG="${{ steps.img.outputs.app }}"
TAG="${{ steps.img.outputs.tag }}"
docker build -f Dockerfile -t "${IMG}:${TAG}" .
docker push "${IMG}:${TAG}"
- name: Build news-scraper image
if: steps.plan.outputs.scraper == '1'
run: |
set -ex
IMG="${{ steps.img.outputs.scraper }}"
SHA="${{ steps.img.outputs.sha }}"
docker build -f news/scraper/Dockerfile -t "${IMG}:latest" -t "${IMG}:${SHA}" \
-t "localhost/osint-news-scraper:latest" news/scraper
docker push "${IMG}:latest"
docker push "${IMG}:${SHA}"
TAG="${{ steps.img.outputs.tag }}"
docker build -f news/scraper/Dockerfile -t "${IMG}:${TAG}" news/scraper
docker push "${IMG}:${TAG}"
- name: Build news-summarizer image
if: steps.plan.outputs.summarizer == '1'
run: |
set -ex
IMG="${{ steps.img.outputs.summarizer }}"
SHA="${{ steps.img.outputs.sha }}"
docker build -f news/summerizer/Dockerfile -t "${IMG}:latest" -t "${IMG}:${SHA}" \
-t "localhost/osint-news-summarizer:latest" news/summerizer
docker push "${IMG}:latest"
docker push "${IMG}:${SHA}"
TAG="${{ steps.img.outputs.tag }}"
docker build -f news/summerizer/Dockerfile -t "${IMG}:${TAG}" news/summerizer
docker push "${IMG}:${TAG}"
- name: Build / refresh Timescale+PostGIS image
if: steps.plan.outputs.pg == '1'
run: |
set -ex
PG="${{ steps.img.outputs.pg }}"
SHA="${{ steps.img.outputs.sha }}"
if docker build -f Dockerfile.pg -t "${PG}:latest" -t "${PG}:${SHA}" \
-t "localhost/osint-dashboard-pg:latest" .; then
docker push "${PG}:latest"
docker push "${PG}:${SHA}"
elif docker image inspect "localhost/osint-dashboard-pg:latest" >/dev/null 2>&1; then
echo "WARN: Dockerfile.pg build failed; keeping existing local pg image"
else
echo "ERROR: cannot build or find osint-dashboard-pg image"
exit 1
fi
- name: Deploy on runner host (compose)
run: |
set -ex
cd "${GITHUB_WORKSPACE}"
APP="${{ steps.plan.outputs.app }}"
SCRAPER="${{ steps.plan.outputs.scraper }}"
SUM="${{ steps.plan.outputs.summarizer }}"
PG="${{ steps.plan.outputs.pg }}"
COMPOSE="${{ steps.plan.outputs.compose }}"
SVCS=()
[ "$APP" = "1" ] && SVCS+=(app ingester camera-service)
[ "$SCRAPER" = "1" ] && SVCS+=(news-scraper)
[ "$SUM" = "1" ] && SVCS+=(news-summarizer)
if [ "$COMPOSE" = "1" ]; then
# compose/script change: bounce workers so env/command updates apply.
# Still do not bounce Postgres.
for s in app ingester camera-service news-scraper news-summarizer; do
case " ${SVCS[*]} " in
*" $s "*) ;;
*) SVCS+=("$s") ;;
esac
done
fi
chmod +x scripts/compose-reup.sh
if [ "$PG" = "1" ]; then
FORCE_RECREATE_DB=1 COMPOSE_PROJECT_NAME=osint-dashboard COMPOSE_PROFILES=ingest \
scripts/compose-reup.sh "${SVCS[@]}" db
elif [ "${#SVCS[@]}" -gt 0 ]; then
COMPOSE_PROJECT_NAME=osint-dashboard COMPOSE_PROFILES=ingest \
scripts/compose-reup.sh "${SVCS[@]}"
else
echo "No image or compose changes — leave running containers alone"
docker compose --profile ingest ps
fi
docker image prune -f
echo "osint-dashboard deploy done; db image left in place unless pg=1"
IMG="${{ steps.img.outputs.pg }}"
TAG="${{ steps.img.outputs.tag }}"
docker build -f Dockerfile.pg -t "${IMG}:${TAG}" .
docker push "${IMG}:${TAG}"
- name: Summary
if: always()
run: |
TAG="${{ steps.img.outputs.tag }}"
PUB="${{ steps.img.outputs.pub }}"
{
echo "## Image plan"
echo "- app: \`${{ steps.plan.outputs.app }}\`"
@ -245,5 +200,23 @@ jobs:
echo "- news-summarizer: \`${{ steps.plan.outputs.summarizer }}\`"
echo "- pg (Timescale): \`${{ steps.plan.outputs.pg }}\`"
echo
echo "Postgres is rebuilt/pulled only when \`Dockerfile.pg\` changes (or workflow_dispatch rebuild_pg)."
if [ -n "$TAG" ]; then
echo "## Pin in homek8s (apps/base/osint)"
echo "Pushed tag: \`${TAG}\`. Set the workload images in"
echo "\`apps/base/osint/kustomization.yaml\` to:"
echo
echo '```yaml'
echo "images:"
echo " - name: ${PUB}/${OWNER}/osint-dashboard"
echo " newTag: ${TAG}"
echo " - name: ${PUB}/${OWNER}/osint-news-scraper"
echo " newTag: ${TAG}"
echo " - name: ${PUB}/${OWNER}/osint-news-summarizer"
echo " newTag: ${TAG}"
echo '```'
else
echo "_No tag computed — the earlier steps failed before Image refs._"
fi
echo
echo "Postgres is rebuilt only when \`Dockerfile.pg\` changes (or workflow_dispatch rebuild_pg)."
} >> "$GITHUB_STEP_SUMMARY"