perf: add BuildKit cache mounts to speed up Go build in Docker
Deploy PR-Helper / deploy (push) Successful in 3m28s
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:
+4
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user