Created
January 5, 2021 16:35
-
-
Save ravenjm/8b44f4ce78fcf1f316c3261719700b25 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
# STEP 1 build executable binary | |
FROM golang:alpine as builder | |
COPY . $GOPATH/src/ | |
WORKDIR $GOPATH/src/ | |
#add git to builder image | |
RUN apk update && apk add git | |
#get dependancies | |
RUN go get -d -v | |
#build the binary | |
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/gocalc | |
# STEP 2 build a small image | |
# start from scratch | |
FROM scratch | |
# Copy our static executable | |
COPY --from=builder /go/bin/gocalc /go/bin/gocalc | |
ENTRYPOINT ["/go/bin/gocalc"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment