FROM golang:1.14 AS builder COPY . /app WORKDIR /app ARG GOARCH=amd64 RUN go generate RUN \ CGO_ENABLED=0 \ GOOS=linux \ GOPROXY=https://proxy.golang.org,direct \ go build -ldflags "-s -w" -o main . FROM scratch COPY contrib/etc/group contrib/etc/passwd /etc/ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=builder /app/main /main USER user ENTRYPOINT ["/main"] CMD ["server"]