perf: cache go modules and build output in CI (#8)
The Dockerfile uses BuildKit cache mounts so module downloads and compiled packages survive a go.sum bump, and the test job restores the runner-local cache server that act_runner already exposes.
This commit is contained in:
+10
-3
@@ -1,3 +1,4 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Headless knox node: CLI + MCP stdio + gossip sync, one static binary.
|
||||
#
|
||||
# docker build -t docker.notsosm.art/knox:latest .
|
||||
@@ -9,12 +10,18 @@
|
||||
FROM golang:1.27-alpine AS build
|
||||
WORKDIR /src
|
||||
|
||||
# Dependencies first so source edits do not invalidate the module cache.
|
||||
# Dependencies first so source edits do not invalidate the module layer.
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
go mod download
|
||||
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 go build -trimpath -ldflags='-s -w' -o /out/knox .
|
||||
# Cache mounts persist on the build daemon across builds, so a go.sum change no
|
||||
# longer forces a full re-download and rebuild of every dependency.
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
CGO_ENABLED=0 go build -trimpath -ldflags='-s -w' -o /out/knox .
|
||||
|
||||
FROM alpine:3.22
|
||||
RUN apk add --no-cache ca-certificates \
|
||||
|
||||
Reference in New Issue
Block a user