perf: add BuildKit cache mounts to speed up Go build in Docker
Deploy PR-Helper / deploy (push) Successful in 3m28s

Mount persistent cache for go build and module directories so
subsequent builds only recompile changed packages.
This commit is contained in:
2026-06-21 14:20:34 +08:00
parent 64098a92d3
commit 846288731f
+4 -1
View File
@@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1
# Build stage
FROM golang:1.25-alpine AS builder
WORKDIR /app
@@ -5,7 +6,9 @@ COPY go.mod go.sum ./
ENV GOPROXY=https://goproxy.cn,direct
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o pr-helper .
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 go build -o pr-helper .
# Runtime stage
FROM alpine:3.20