File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change 2
2
3
3
FROM --platform=${BUILDPLATFORM} golang:1.16-alpine as builder
4
4
5
+ # passed by buildkit
6
+ ARG TARGETOS
7
+ ARG TARGETARCH
8
+
5
9
# add CA certificates and TZ for local time
6
- RUN apk --update add ca-certificates tzdata make git
10
+ RUN apk --update add ca-certificates make git
7
11
8
12
# Create and change to the app directory.
9
13
RUN mkdir -p /go/src/app
@@ -20,17 +24,12 @@ RUN --mount=type=cache,target=/go/mod go mod download
20
24
COPY . .
21
25
22
26
# Build the binary.
23
- RUN make
27
+ RUN --mount=type=cache,target=/root/.cache/go-build TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} make
24
28
25
29
# final image
26
- FROM scratch
30
+ # keep it FROM alpine - need to copy secrets-init to target container
31
+ FROM --platform=${TARGETPLATFORM} alpine:3.13
27
32
28
- # copy the binary to the production image from the builder stage.
29
- COPY --from=builder /go/src/app/.bin/secrets-init /secrets-init
30
- # copy certificates
31
- COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
32
- # copy timezone settings
33
- COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
33
+ COPY --from=builder /go/src/app/.bin/secrets-init /usr/local/bin/secrets-init
34
34
35
- ENTRYPOINT ["/secrets-init" ]
36
- CMD ["--version" ]
35
+ CMD ["secrets-init" , "--version" ]
You can’t perform that action at this time.
0 commit comments