Skip to content

Commit 141945f

Browse files
committed
fix file location; base image (alpine), multi-arch
1 parent 8145e05 commit 141945f

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

Dockerfile

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
FROM --platform=${BUILDPLATFORM} golang:1.16-alpine as builder
44

5+
# passed by buildkit
6+
ARG TARGETOS
7+
ARG TARGETARCH
8+
59
# 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
711

812
# Create and change to the app directory.
913
RUN mkdir -p /go/src/app
@@ -20,17 +24,12 @@ RUN --mount=type=cache,target=/go/mod go mod download
2024
COPY . .
2125

2226
# Build the binary.
23-
RUN make
27+
RUN --mount=type=cache,target=/root/.cache/go-build TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} make
2428

2529
# 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
2732

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
3434

35-
ENTRYPOINT ["/secrets-init"]
36-
CMD ["--version"]
35+
CMD ["secrets-init", "--version"]

0 commit comments

Comments
 (0)