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
|
# Build stage
|
||||||
FROM golang:1.25-alpine AS builder
|
FROM golang:1.25-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -5,7 +6,9 @@ COPY go.mod go.sum ./
|
|||||||
ENV GOPROXY=https://goproxy.cn,direct
|
ENV GOPROXY=https://goproxy.cn,direct
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY . .
|
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
|
# Runtime stage
|
||||||
FROM alpine:3.20
|
FROM alpine:3.20
|
||||||
|
|||||||
Reference in New Issue
Block a user