From ca933eef46e7c21347fb54147b531af6d6d81136 Mon Sep 17 00:00:00 2001 From: Mathias Bergqvist Date: Tue, 5 May 2026 07:19:18 +0200 Subject: [PATCH] build(routing): Dockerfile + CD workflow Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/cd.yml | 32 ++++++++++++++++++++++++++++++-- Dockerfile.routing | 30 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 Dockerfile.routing diff --git a/.gitea/workflows/cd.yml b/.gitea/workflows/cd.yml index bf636af..df33664 100644 --- a/.gitea/workflows/cd.yml +++ b/.gitea/workflows/cd.yml @@ -15,6 +15,7 @@ jobs: SERVICE: supervisor IMAGE: gitea.d-ma.be/mathias/supervisor INGESTION_IMAGE: gitea.d-ma.be/mathias/ingestion + ROUTING_IMAGE: gitea.d-ma.be/mathias/routing INFRA_REPO: git@gitea.d-ma.be:mathias/infra.git BUILDKIT_HOST: unix:///run/buildkit/buildkitd.sock steps: @@ -62,6 +63,28 @@ jobs: echo "Built and pushed ${INGESTION_IMAGE}:${IMAGE_TAG}" + - name: Build and push routing image + run: | + set -e + trap 'rm -f /tmp/routing-image.tar' EXIT + IMAGE_TAG="${{ github.sha }}" + echo "Building ${ROUTING_IMAGE}:${IMAGE_TAG}" + + buildctl --addr "${BUILDKIT_HOST}" build \ + --frontend dockerfile.v0 \ + --local context=. \ + --local dockerfile=. \ + --opt filename=Dockerfile.routing \ + --opt build-arg:VERSION="${IMAGE_TAG}" \ + --output type=oci,dest=/tmp/routing-image.tar + + skopeo copy \ + oci-archive:/tmp/routing-image.tar \ + docker://${ROUTING_IMAGE}:${IMAGE_TAG} \ + --dest-creds "${{ secrets.REGISTRY_CREDS }}" + + echo "Built and pushed ${ROUTING_IMAGE}:${IMAGE_TAG}" + - name: Update infra repo run: | set -e @@ -83,10 +106,15 @@ jobs: sed -i "s|gitea.d-ma.be/mathias/ingestion:.*|gitea.d-ma.be/mathias/ingestion:${IMAGE_TAG}|" \ "k3s/apps/${SERVICE}/ingestion-deployment.yaml" + sed -i "s|gitea.d-ma.be/mathias/routing:.*|gitea.d-ma.be/mathias/routing:${IMAGE_TAG}|" \ + "k3s/apps/routing/deployment.yaml" + git config user.email "cd-bot@d-ma.be" git config user.name "CD Bot" - git add "k3s/apps/${SERVICE}/deployment.yaml" "k3s/apps/${SERVICE}/ingestion-deployment.yaml" - git commit -m "chore(deploy): ${SERVICE}+ingestion → ${IMAGE_TAG}" + git add "k3s/apps/${SERVICE}/deployment.yaml" \ + "k3s/apps/${SERVICE}/ingestion-deployment.yaml" \ + "k3s/apps/routing/deployment.yaml" + git commit -m "chore(deploy): supervisor+ingestion+routing → ${IMAGE_TAG}" GIT_SSH_COMMAND="ssh -i ~/.ssh/infra_deploy_key -o IdentitiesOnly=yes" \ git push diff --git a/Dockerfile.routing b/Dockerfile.routing new file mode 100644 index 0000000..946a602 --- /dev/null +++ b/Dockerfile.routing @@ -0,0 +1,30 @@ +# syntax=docker/dockerfile:1 + +# ── Build stage ─────────────────────────────────────────────────────────────── +FROM golang:1.26-bookworm AS builder + +ARG VERSION=dev +WORKDIR /src + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ + go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" \ + -o /out/routing ./cmd/routing + +# ── Runtime stage ───────────────────────────────────────────────────────────── +FROM gcr.io/distroless/base-debian12 + +COPY --from=builder /out/routing /usr/local/bin/routing +COPY config/ /app/config/ + +ENV SUPERVISOR_CONFIG_DIR=/app/config/supervisor +ENV ROUTING_PORT=3210 + +EXPOSE 3210 + +USER 65532:65532 + +ENTRYPOINT ["/usr/local/bin/routing"]