build: Add cache mounts to Dockerfile for faster Go binary compilation.

This commit is contained in:
2026-01-30 07:51:59 +08:00
parent 076a9f92aa
commit d52773ebd6

View File

@@ -51,8 +51,10 @@ COPY backend/ ./
# Copy frontend dist from previous stage
COPY --from=frontend-builder /app/frontend/dist ./internal/web/dist
# Build the binary with embed tag
RUN GOTOOLCHAIN=auto CGO_ENABLED=1 GOOS=linux go build \
# Build the binary with embed tag (使用缓存加速)
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOTOOLCHAIN=auto CGO_ENABLED=1 GOOS=linux go build \
-tags embed \
-ldflags="-s -w" \
-o /app/codex-pool \