FROM golang:1.19 as builder WORKDIR /workdir ADD go.mod go.mod ADD go.sum go.sum ENV GOPROXY=https://goproxy.cn,direct GO111MODULE=on RUN go mod download ADD main.go main.go ADD pkg pkg RUN GOOS=linux GOARCH=amd64 go build -o /appname main.go FROM scratch COPY --from=builder /workdir/appname / ENTRYPOINT [ "/appname" ]