From 3f5ebc4afd8d11680570a1061be69fb3abc14a5b Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Sun, 12 Jul 2026 22:18:44 +0200 Subject: [PATCH] fix(ci): authenticate tramiton-core fetch in the agent image build (main deploys) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PR `check` job configures git auth for the private tramiton-core dependency, but the main-branch `deploy-agent` job builds `Dockerfile.agent` where cargo also fetches tramiton-core — inside the image build, with no credentials — so agent image builds on main failed. Inject the PAT as a BuildKit secret (never baked into a layer): - Dockerfile.agent: `RUN --mount=type=secret,id=tramiton_token` configures the same https-insteadOf rewrite + CARGO_NET_GIT_FETCH_WITH_CLI before cargo build. - deploy-agent: `DOCKER_BUILDKIT=1 docker build --secret id=tramiton_token,env= TRAMITON_FETCH_TOKEN ...`, reusing the existing TRAMITON_FETCH_TOKEN secret. Only the agent image depends on tramiton-core; dashboard/mcp/docs builds are unaffected. Self-tests on merge (deploy-agent runs when Dockerfile.agent changes). Refs #118. Co-Authored-By: Claude Fable 5 --- .gitea/workflows/ci.yml | 7 ++++++- Dockerfile.agent | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index aba5c09..d8ec3a1 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -191,13 +191,18 @@ jobs: image: docker:27-cli steps: - name: Build, push and trigger orca redeploy + env: + # PAT for fetching the private tramiton-core git dependency during the + # image build (injected as a BuildKit secret, never baked into a layer). + TRAMITON_FETCH_TOKEN: ${{ secrets.TRAMITON_FETCH_TOKEN }} run: | apk add --no-cache git curl openssl git init && git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" git fetch --depth=1 origin "${GITHUB_SHA}" && git checkout FETCH_HEAD IMAGE=registry.meghsakha.com/compliance-agent echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login registry.meghsakha.com -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin - docker build -f Dockerfile.agent -t "$IMAGE:latest" -t "$IMAGE:${GITHUB_SHA}" . + DOCKER_BUILDKIT=1 docker build --secret id=tramiton_token,env=TRAMITON_FETCH_TOKEN \ + -f Dockerfile.agent -t "$IMAGE:latest" -t "$IMAGE:${GITHUB_SHA}" . docker push "$IMAGE:latest" && docker push "$IMAGE:${GITHUB_SHA}" PAYLOAD=$(printf '{"ref":"refs/heads/main","repository":{"full_name":"sharang/compliance-scanner-agent"},"head_commit":{"id":"%s","message":"deploy agent"}}' "${GITHUB_SHA}") SIG=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "${{ secrets.ORCA_WEBHOOK_SECRET }}" | awk '{print $2}') diff --git a/Dockerfile.agent b/Dockerfile.agent index 891a6b0..adc4a9d 100644 --- a/Dockerfile.agent +++ b/Dockerfile.agent @@ -2,7 +2,16 @@ FROM rust:1.94-bookworm AS builder WORKDIR /app COPY . . -RUN cargo build --release -p compliance-agent +# compliance-agent depends on the private tramiton-core git repo. Authenticate +# the fetch with a PAT passed as a BuildKit secret (never baked into a layer). +# Build with: DOCKER_BUILDKIT=1 docker build --secret id=tramiton_token,env=TRAMITON_FETCH_TOKEN ... +RUN --mount=type=secret,id=tramiton_token \ + if [ -s /run/secrets/tramiton_token ]; then \ + git config --global \ + url."https://sharang:$(cat /run/secrets/tramiton_token)@gitea.meghsakha.com/".insteadOf \ + "ssh://git@gitea.meghsakha.com:22222/"; \ + fi && \ + CARGO_NET_GIT_FETCH_WITH_CLI=true cargo build --release -p compliance-agent FROM debian:bookworm-slim RUN apt-get update && apt-get install -y ca-certificates libssl3 git curl python3 python3-pip npm golang-go php-cli && rm -rf /var/lib/apt/lists/* -- 2.54.0