Created
December 19, 2019 13:28
-
-
Save bluebeel/a22a58816c51f70071bd7ba5206cbe41 to your computer and use it in GitHub Desktop.
Golang docker file
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
# Base build image | |
FROM golang:latest as build-env | |
# All these steps will be cached | |
RUN mkdir /api | |
WORKDIR /api | |
COPY go.mod . | |
COPY go.sum . | |
# Get dependancies - will also be cached if we won't change mod/sum | |
RUN go mod download | |
# COPY the source code as the last step | |
COPY . . | |
# Build the binary | |
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o /go/bin/api | |
#In this last stage, we start from a fresh Alpine image, to reduce the image size and not ship the Go compiler in our production artifacts. | |
FROM alpine AS api | |
# We add the certificates to be able to verify remote weaviate instances | |
RUN apk --no-cache add ca-certificates | |
# Finally we copy the statically compiled Go binary. | |
COPY --from=build-env /go/bin/api /go/bin/api | |
EXPOSE 8080 | |
ENTRYPOINT ["/go/bin/api"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment