# STEP 1 FROM golang:1.11-stretch as builder COPY . /srv/app WORKDIR /srv/app #get dependancies RUN go mod download #build the binary RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o /go/bin/app # STEP 2 # start from scratch FROM scratch # Copy our static executable WORKDIR /usr/app COPY --from=builder /go/bin/app . ENTRYPOINT ["./app"]