Build your Go image | Docker Documentation

PHOTO EMBED

Tue Feb 08 2022 20:28:15 GMT+0000 (UTC)

Saved by @joel113 #go

# syntax=docker/dockerfile:1

##
## Build
##
FROM golang:1.16-buster AS build

WORKDIR /app

COPY go.mod ./
COPY go.sum ./
RUN go mod download

COPY *.go ./

RUN go build -o /docker-gs-ping

##
## Deploy
##
FROM gcr.io/distroless/base-debian10

WORKDIR /

COPY --from=build /docker-gs-ping /docker-gs-ping

EXPOSE 8080

USER nonroot:nonroot

ENTRYPOINT ["/docker-gs-ping"]
content_copyCOPY

https://docs.docker.com/language/golang/build-images/