This commit is contained in:
Vladislav Kunetskiy
2026-10-21 21:22:42 +03:00
parent f4bd361f12
commit 464db7fdd6
238 changed files with 13332 additions and 704 deletions
+14 -2
View File
@@ -4,8 +4,14 @@ ARG GO_VERSION=1.27.1
ARG ALPINE_VERSION=3.22
FROM golang:${GO_VERSION}-alpine AS build
ARG TARGETOS=linux
ARG TARGETARCH=amd64
# Platform of the produced binaries. Left empty on purpose: the classic builder
# does not supply these args, and the previous hardcoded `amd64` default silently
# produced x86-64 binaries inside an arm64 image. Those ran under emulation and
# the Go runtime crashed under load (fatals like "found pointer to free object").
# Empty means "build for the builder's own platform"; cross-compile explicitly:
# docker build --build-arg TARGETARCH=amd64 ...
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=dev
ENV GOTOOLCHAIN=local
WORKDIR /opt
@@ -13,6 +19,12 @@ WORKDIR /opt
COPY go.mod go.sum ./
RUN go mod download
# The Go compiler spikes well above 1 GiB per package on large dependencies, so
# an unbounded parallel build OOMs small Docker VMs and CI runners. Cap
# parallelism; override with --build-arg GOFLAGS=-p=$(nproc) on a bigger host.
ARG GOFLAGS="-p=2"
ENV GOFLAGS=$GOFLAGS
COPY . .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -trimpath -buildvcs=false -tags timetzdata \