Last active
December 9, 2022 12:45
-
-
Save jinjie/1ea7e8029b4a97564e7f655d652a928e to your computer and use it in GitHub Desktop.
Example Dockerfile creating lean image for Go apps (Multi-stage build)
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.19-alpine as build | |
WORKDIR /app/ | |
ADD . /app/ | |
RUN go get | |
RUN CGO_ENABLED=0 go build -o mainApp . | |
FROM scratch | |
COPY --from=build /app/mainApp / | |
CMD [ "/mainApp" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment