Last active
April 21, 2022 08:06
-
-
Save wattanakorn495/85460cc78a63336a001e9c9c6cd5e0db to your computer and use it in GitHub Desktop.
multi stage docker example
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-alpine as builder | |
LABEL maintainer="Wattanakorn Intanon <watttanakorn.in@avilon.co.th>" | |
RUN apk update && apk add gcc git | |
RUN mkdir /mqtt-aggregator | |
WORKDIR /mqtt-aggregator | |
COPY go.mod . | |
COPY go.sum . | |
COPY . . | |
RUN go build ./... | |
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o mqtt-aggregator | |
FROM alpine:latest | |
RUN apk --no-cache add ca-certificates | |
WORKDIR /app/ | |
COPY --from=builder /mqtt-aggregator/mqtt-aggregator . | |
ENTRYPOINT ["./mqtt-aggregator"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment