Goで実装したプログラムのコンテナイメージ化
This content is a draft and will not be included in production builds.
ko-build/ko が使えるなら、これがベストだと思う。
使えないのなら、—mount=type=bind でローカルのファイルシステムをマウントしつつ、—mount=type=cache でGoモジュールをキャッシュするといい。
# syntax=docker/dockerfile:1
FROM golang:1.23 AS builderWORKDIR /go/srcRUN --mount=type=bind,target=. go build -o /go/bin/server
FROM gcr.io/distroless/static-debian12:nonroot-amd64 AS workerCOPY --from=builder /go/bin/server /var/runtime/bootstrap
ENTRYPOINT ["/var/runtime/bootstrap"]