fix(deploy): build server images with cgo
Deployment Config CI / Deployment Config (push) Successful in 3m27s

This commit is contained in:
2026-05-01 00:22:30 +08:00
parent 79915b5aa7
commit cbf8a8b36a
3 changed files with 37 additions and 9 deletions
+10 -7
View File
@@ -1,22 +1,25 @@
# syntax=docker/dockerfile:1
# ─── Stage 1: Build Go binaries ───────────────────────────────────────────────
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder
FROM golang:1.23-alpine AS builder
ARG SERVICE=tenant-api
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG TARGETOS
ARG TARGETARCH
RUN apk --no-cache add ca-certificates git
RUN apk --no-cache add ca-certificates git build-base
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
ARG SERVICE=tenant-api
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=1 GOOS="${TARGETOS:-$(go env GOOS)}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \
go build -trimpath -ldflags="-s -w" \
-o /bin/service ./cmd/${SERVICE}