-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0583c1b
commit 8defd1c
Showing
3 changed files
with
54 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,28 @@ | ||
# syntax = docker/dockerfile:experimental | ||
|
||
FROM --platform=${BUILDPLATFORM} golang:1.16-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 | ||
# keep it FROM alpine - need to copy secrets-init to target container | ||
FROM --platform=${TARGETPLATFORM} alpine:3.13 | ||
|
||
COPY --from=builder /go/src/app/.bin/secrets-init /usr/local/bin/secrets-init | ||
|
||
CMD ["secrets-init", "--version"] | ||
FROM scratch | ||
# copy the binary to the production image from the builder stage. | ||
COPY --from=builder /go/src/app/.bin/secrets-init /secrets-init | ||
ENTRYPOINT ["/secrets-init"] | ||
CMD ["--version"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters