fix(deploy): build server images with cgo
Deployment Config CI / Deployment Config (push) Successful in 3m27s
Deployment Config CI / Deployment Config (push) Successful in 3m27s
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
@@ -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}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user