FROM golang:1.19-alpine as builder ARG service RUN go install github.com/bufbuild/buf/cmd/buf@v1.17.0 RUN go install github.com/kyleconroy/sqlc/cmd/sqlc@latest COPY . /go/src WORKDIR /go/src/${service} RUN /go/bin/sqlc generate -f /go/src/sqlc.yaml RUN /go/bin/buf mod update /go/src/src \ && /go/bin/buf generate RUN go mod tidy \ && CGO_ENABLED=0 go build -v -gcflags="-trimpath=$(go env GOPATH)" -asmflags="-trimpath=$(go env GOPATH)" -o /opt/${service} /go/src/${service} FROM alpine as production ARG service COPY --from=builder /opt/${service} /opt/${service} ENV SERVICE=${SERVICE} ENTRYPOINT ['/opt/${SERVICE}']