Created
January 8, 2018 21:38
-
-
Save r6m/0f5c11bd709a8acd606bd59420bf1e52 to your computer and use it in GitHub Desktop.
golang multi stage docker build
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
## builder docker | |
FROM golang:1.9.2 as builder | |
WORKDIR /go/src/buddytest | |
copy ./ . | |
RUN curl https://glide.sh/get | sh | |
RUN glide install | |
RUN go test | |
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app . | |
## final docker | |
FROM alpine:latest | |
RUN apk --no-cache add ca-certificates | |
WORKDIR /app | |
# notice [--from]: here we get app file from previous docker build stage | |
COPY --from=builder /go/src/buddytest/app . | |
CMD ["./app"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pipe docker builds for less size images