Created
November 29, 2019 07:35
-
-
Save jrevillas/bf642637f14d36ce5741dee721ce2ce4 to your computer and use it in GitHub Desktop.
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
ARG ALPINE_VERSION=3.10 | |
ARG GOLANG_VERSION=1.13.4 | |
FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS builder | |
RUN mkdir /tmp/unprivileged && \ | |
echo 'service:x:101:101:service:/:' > /tmp/unprivileged/passwd && \ | |
echo 'service:x:101:' > /tmp/unprivileged/group | |
RUN apk update && \ | |
apk add --no-cache ca-certificates git tzdata && \ | |
update-ca-certificates | |
WORKDIR /go/src/app | |
COPY ./go.mod ./ | |
RUN go mod download | |
COPY . . | |
RUN CGO_ENABLED=0 go build -installsuffix 'static' -o /app | |
FROM scratch | |
COPY --from=builder /tmp/unprivileged/group /tmp/unprivileged/passwd /etc/ | |
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | |
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo | |
COPY --from=builder /app /app | |
USER 101:101 | |
ENTRYPOINT ["/app"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment