Created
December 14, 2021 00:02
-
-
Save cnp96/73f95a34698c1cb286b6915bd0465f1e to your computer and use it in GitHub Desktop.
Docker build for Go app
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.16.4-alpine as base | |
WORKDIR /app/go | |
COPY . . | |
RUN go mod download | |
FROM base as image-dev | |
RUN go get github.com/cosmtrek/air | |
EXPOSE 9000 | |
CMD $(go env GOPATH)/bin/air | |
FROM base as builder | |
RUN mkdir dist | |
RUN go build -o dist/web . | |
FROM alpine:3.15 as image-prod | |
WORKDIR /app | |
COPY --from=builder ./app/go/dist/ ./ | |
EXPOSE 9000 | |
CMD ./web |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment