The PR `check` job authenticates the private tramiton-core git fetch, 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 fail**. Fix: inject the PAT as a **BuildKit secret** (never baked into an image layer). - `Dockerfile.agent`: `RUN --mount=type=secret,id=tramiton_token …` applies the same `https`-insteadOf rewrite + `CARGO_NET_GIT_FETCH_WITH_CLI=true` 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 unaffected). **Self-tests on merge** — changing `Dockerfile.agent` makes `detect-changes` run `deploy-agent`. Note: couldn't fully run the image build locally (no PAT value on hand + no `.dockerignore` so the context is large), but this mirrors the working PR-stage auth and uses standard BuildKit secret injection. Assumes the deploy runner's Docker daemon supports BuildKit (docker:27-cli → yes). --------- Co-authored-by: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Reviewed-on: #143
57 lines
2.3 KiB
Docker
57 lines
2.3 KiB
Docker
FROM rust:1.94-bookworm AS builder
|
|
|
|
WORKDIR /app
|
|
COPY . .
|
|
# 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/*
|
|
|
|
# Install Cargo (minimal, for cargo metadata / cargo audit / generate-lockfile)
|
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal
|
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
|
RUN cargo install cargo-audit
|
|
|
|
# Install Composer for PHP dependency resolution
|
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
|
|
# Install Bundler for Ruby dependency resolution
|
|
RUN apt-get update && apt-get install -y ruby && rm -rf /var/lib/apt/lists/* && gem install bundler
|
|
|
|
# Install syft for SBOM generation
|
|
RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
|
|
|
|
# Install gitleaks for secret detection
|
|
RUN curl -sSfL https://github.com/gitleaks/gitleaks/releases/download/v8.21.2/gitleaks_8.21.2_linux_x64.tar.gz \
|
|
| tar -xz -C /usr/local/bin gitleaks
|
|
|
|
# Install semgrep for static analysis
|
|
RUN pip3 install --break-system-packages semgrep
|
|
|
|
# Install ruff for Python linting
|
|
RUN pip3 install --break-system-packages ruff
|
|
|
|
COPY --from=builder /app/target/release/compliance-agent /usr/local/bin/compliance-agent
|
|
|
|
# Copy documentation for the help chat assistant
|
|
COPY --from=builder /app/README.md /app/README.md
|
|
COPY --from=builder /app/docs /app/docs
|
|
ENV HELP_DOCS_PATH=/app
|
|
|
|
# Ensure SSH key directory exists
|
|
RUN mkdir -p /data/compliance-scanner/ssh
|
|
|
|
EXPOSE 3001 3002
|
|
|
|
ENTRYPOINT ["compliance-agent"]
|
|
|