-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (51 loc) · 1.79 KB
/
Copy pathDockerfile
File metadata and controls
66 lines (51 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# syntax=docker/dockerfile:1.7
###
# Build a static secrets-sync binary for the requested platform.
# Tests now run in CI (outside Docker), so this Dockerfile focuses purely
# on compiling and packaging the runtime image.
###
FROM golang:1.26.6-trixie AS builder
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG TARGETVARIANT
ARG CGO_ENABLED=0
ARG VERSION=dev
ENV CGO_ENABLED=${CGO_ENABLED} \
GOTOOLCHAIN=auto
WORKDIR /src
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
GOARM=${TARGETVARIANT#v} \
go build -trimpath \
-ldflags="-s -w" \
-o /out/secrets-sync ./cmd/secrets-sync && \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
GOARM=${TARGETVARIANT#v} \
go build -trimpath \
-ldflags="-s -w" \
-o /out/secrets-sync-controller ./cmd/secrets-sync-controller
###
# Runtime image: distroless static Debian with no shell or package manager.
###
FROM gcr.io/distroless/static-debian13:nonroot AS runtime
ARG VERSION=dev
ARG SECRETS_SYNC_CONFIG=/etc/secrets-sync/config.yaml
ENV SECRETS_SYNC_CONFIG=${SECRETS_SYNC_CONFIG} \
SECRETS_SYNC_VERSION=${VERSION}
LABEL org.opencontainers.image.title="secrets-sync" \
org.opencontainers.image.source="https://github.com/jbcom/secrets-sync" \
org.opencontainers.image.version=${VERSION}
WORKDIR /app
COPY --from=builder /out/secrets-sync /usr/local/bin/secrets-sync
COPY --from=builder /out/secrets-sync-controller /usr/local/bin/secrets-sync-controller
# Default command - Viper reads SECRETS_SYNC_* env vars directly
ENTRYPOINT ["/usr/local/bin/secrets-sync"]
CMD ["pipeline"]