Files
attest-provider/Dockerfile

39 lines
1000 B
Docker
Raw Normal View History

2024-05-23 10:52:35 -05:00
ARG BUILDERIMAGE="golang:1.22"
2024-05-23 10:19:55 -05:00
ARG BASEIMAGE="gcr.io/distroless/static:nonroot"
FROM ${BUILDERIMAGE} as builder
2024-05-23 10:19:55 -05:00
ARG LDFLAGS
ENV GO111MODULE=on \
CGO_ENABLED=0
2024-05-23 10:19:55 -05:00
2024-06-28 16:59:35 +01:00
WORKDIR /app
2024-05-23 10:19:55 -05:00
COPY . .
# --- This block can be replaced by `RUN go mod download` when github.com/docker/attest is public
2024-05-23 10:52:35 -05:00
ENV GOPRIVATE="github.com/docker/attest"
2024-06-11 11:22:57 +01:00
RUN --mount=type=cache,target=$GOPATH/pkg/mod --mount=type=secret,id=GITHUB_TOKEN <<EOT
2024-05-23 10:52:35 -05:00
set -e
GITHUB_TOKEN=${GITHUB_TOKEN:-$(cat /run/secrets/GITHUB_TOKEN)}
if [ -n "$GITHUB_TOKEN" ]; then
echo "Setting GitHub access token"
git config --global "url.https://x-access-token:${GITHUB_TOKEN}@github.com.insteadof" "https://github.com"
fi
go mod download
EOT
# ---
2024-06-11 11:22:57 +01:00
RUN --mount=type=cache,target=$GOPATH/pkg/mod --mount=type=cache,target=/root/.cache/go-build make build
2024-05-23 10:19:55 -05:00
FROM ${BASEIMAGE}
2024-06-28 16:59:35 +01:00
COPY --from=builder /app/bin/attest /
2024-05-23 10:19:55 -05:00
2024-06-28 16:59:35 +01:00
COPY --from=builder --chown=65532:65532 /app/certs/tls.crt /app/certs/tls.key /certs/
2024-05-23 10:19:55 -05:00
USER 65532:65532
2024-05-23 10:52:35 -05:00
ENTRYPOINT ["/attest"]