File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 5252 type=raw,value=latest,enable={{is_default_branch}}
5353
5454 - name : Build and push Docker image
55+ id : build
5556 uses : docker/build-push-action@v5
5657 with :
5758 context : .
Original file line number Diff line number Diff line change 33FROM golang:1.24-alpine AS builder
44
55# Set GOPROXY for faster downloads
6- ENV GOPROXY=https://goproxy.cn,https://proxy.golang.org,direct
6+ ENV GOPROXY=https://goproxy.cn,https://proxy.golang.org,direct \
7+ CGO_ENABLED=0 \
8+ GOOS=linux \
9+ GOARCH=amd64
710
811WORKDIR /build
912
@@ -17,10 +20,12 @@ RUN go mod download
1720# Copy source code
1821COPY core/ ./
1922
20- # Build static binary
21- RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
22- -a -installsuffix cgo \
23- -ldflags '-extldflags "-static" -s -w' \
23+ # Build static binary with cache optimization
24+ RUN --mount=type=cache,target=/root/.cache/go-build \
25+ go build \
26+ -trimpath \
27+ -ldflags='-s -w -extldflags "-static"' \
28+ -p=$(nproc) \
2429 -o /apprun ./cmd/server/main.go
2530
2631# Stage 2: Production - Minimal runtime image
You can’t perform that action at this time.
0 commit comments