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
+16 -2
View File
@@ -5,12 +5,26 @@ on:
branches:
- main
paths:
- "server/**"
- "server/**/*.go"
- "server/**/*.sql"
- "server/**/*.yaml"
- "server/**/*.yml"
- "server/go.mod"
- "server/go.sum"
- "server/Makefile"
- "server/scripts/**"
pull_request:
branches:
- main
paths:
- "server/**"
- "server/**/*.go"
- "server/**/*.sql"
- "server/**/*.yaml"
- "server/**/*.yml"
- "server/go.mod"
- "server/go.sum"
- "server/Makefile"
- "server/scripts/**"
workflow_dispatch:
permissions:
+11
View File
@@ -46,5 +46,16 @@ jobs:
docker compose -f deploy/docker-compose.yaml config >/tmp/compose.yaml
docker compose -f deploy/docker-compose.yaml -f deploy/docker-compose.offline.yaml config >/tmp/compose-offline.yaml
- name: Smoke build server runtime image
run: |
DOCKER_BUILDKIT=1 docker build \
--platform linux/amd64 \
--target runtime \
--build-arg SERVICE=tenant-api \
--tag geo-rankly/tenant-api:ci-smoke \
-f server/Dockerfile \
server/
docker image rm geo-rankly/tenant-api:ci-smoke >/dev/null 2>&1 || true
- name: Validate shell scripts
run: bash -n deploy/scripts/package.sh deploy/scripts/load-and-start.sh
+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}