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:
+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