Skip to content

Instantly share code, notes, and snippets.

@AngerM
Last active October 21, 2020 04:02
Show Gist options
  • Save AngerM/08d538e1348742cd1ec6d27ab1996316 to your computer and use it in GitHub Desktop.
Save AngerM/08d538e1348742cd1ec6d27ab1996316 to your computer and use it in GitHub Desktop.
GOLANG MODULES CGO Enabled Docker build
FROM golang:buster AS build_base
WORKDIR /go/src/app
COPY go.mod .
COPY go.sum .
ENV GO111MODULE=on
ENV GOOS=linux
ENV GOARCH=amd64
RUN go mod download
FROM build_base as builder
COPY . .
RUN go build -o app
#final stage
FROM debian:buster-slim
RUN apt update
RUN apt install -y ca-certificates
COPY --from=builder /go/src/app/app /app
ENTRYPOINT ./app
EXPOSE 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment