Created
November 5, 2019 03:01
-
-
Save cherihung/08dd99f520865a10e11fc19ab65af06e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 1 choose a compiler OS | |
FROM golang:alpine AS builder | |
# 2 (optional) label the compiler image | |
LABEL stage=builder | |
# 3 (optional) install any compiler-only dependencies | |
RUN apk add --no-cache gcc libc-dev | |
WORKDIR /workspace | |
# 4 copy all the source files | |
COPY . . | |
# 5 build the GO program | |
RUN CGO_ENABLED=0 GOOS=linux go build -a | |
# 6 choose a runtime OS | |
FROM alpine AS final | |
# 7 | |
ARG ENV | |
WORKDIR / | |
# 8 copy from builder the GO executable file | |
COPY --from=builder /workspace/mygoexecutable . | |
COPY --from=builder /workspace/_envs/env_$ENV.yaml ./_envs/ | |
# 9 execute the program upon start | |
CMD [ "./mygoexecutable" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment