Last active
September 4, 2019 14:06
-
-
Save mustafaturan/7c477126ee7ad3f54b5de5b68b7ec384 to your computer and use it in GitHub Desktop.
Go - Dockerfile - 9.22MB
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
FROM golang:1.13 as build | |
WORKDIR /app | |
COPY go.mod go.sum ./ | |
RUN GO111MODULE=on go mod download | |
COPY . . | |
RUN CGO_ENABLED=0 go build -v | |
# Create a "nobody" non-root user for the next image by crafting an /etc/passwd | |
# file that the next image can copy in. This is necessary since the next image | |
# is based on scratch, which doesn't have adduser, cat, echo, or even sh. | |
RUN echo "nobody:x:65534:65534:Nobody:/:" > /etc_passwd | |
# No need extra files | |
FROM scratch | |
ENV PORT=3000 | |
COPY --from=build /etc/ssl/certs/ /etc/ssl/certs/ | |
COPY --from=build /app/<myawesomeappname> / | |
COPY --from=build /etc_passwd /etc/passwd | |
USER nobody | |
CMD ["/<myawesomeappname>"] | |
# Replace <myawesomeappname> with your app name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment