-
Notifications
You must be signed in to change notification settings - Fork 31
/
Dockerfile
33 lines (30 loc) · 1.06 KB
/
Dockerfile
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
# syntax = docker/dockerfile:experimental
FROM --platform=${BUILDPLATFORM} golang:1.22-alpine as builder
# passed by buildkit
ARG TARGETOS
ARG TARGETARCH
# add CA certificates and TZ for local time
RUN apk --update add ca-certificates make git
# Create and change to the app directory.
RUN mkdir -p /go/src/app
WORKDIR /go/src/app
# Retrieve application dependencies.
# This allows the container build to reuse cached dependencies.
# Expecting to copy go.mod and if present go.sum.
COPY go.mod .
COPY go.sum .
RUN --mount=type=cache,target=/go/mod go mod download
# Copy local code to the container image.
COPY . .
# Build the binary.
RUN --mount=type=cache,target=/root/.cache/go-build TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} make
# final image
FROM busybox:1.36
# copy certificates
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# copy the binary to the production image from the builder stage.
COPY --from=builder /go/src/app/.bin/secrets-init /secrets-init
RUN adduser -D -u 1000 secrets-init
USER 1000
ENTRYPOINT ["/secrets-init"]
CMD ["--version"]