Compare commits
2
Commits
b0ce2fb67c
...
fd45c2c0d3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd45c2c0d3 | ||
|
|
818c9881be |
+11
-4
@@ -4,7 +4,10 @@
|
|||||||
# That is deliberate — see tasks/6.1-hardened-image.md. It also means the binary
|
# That is deliberate — see tasks/6.1-hardened-image.md. It also means the binary
|
||||||
# must be fully static, hence CGO_ENABLED=0.
|
# must be fully static, hence CGO_ENABLED=0.
|
||||||
|
|
||||||
FROM golang:1.25-bookworm AS build
|
# --platform=$BUILDPLATFORM pins the build stage to the machine doing the
|
||||||
|
# building, then Go cross-compiles to $TARGETARCH. Without it, building an
|
||||||
|
# amd64 image from an arm64 workstation runs the whole toolchain under QEMU.
|
||||||
|
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS build
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
@@ -15,13 +18,17 @@ RUN go mod download
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# VERSION is stamped in by CI as the commit SHA so a running pod can be traced
|
# VERSION is stamped in so a running pod can be traced back to an exact build.
|
||||||
# back to an exact commit.
|
|
||||||
ARG VERSION=dev
|
ARG VERSION=dev
|
||||||
|
|
||||||
|
# TARGETARCH is supplied by buildx from --platform. Defaulted to amd64 because
|
||||||
|
# every node in the cluster is amd64; a plain `docker build` on an arm64
|
||||||
|
# workstation would otherwise silently produce an unrunnable image.
|
||||||
|
ARG TARGETARCH=amd64
|
||||||
|
|
||||||
# -trimpath strips local filesystem paths from the binary.
|
# -trimpath strips local filesystem paths from the binary.
|
||||||
# -w -s drop DWARF and the symbol table; nothing debugs off the production image.
|
# -w -s drop DWARF and the symbol table; nothing debugs off the production image.
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build \
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build \
|
||||||
-trimpath \
|
-trimpath \
|
||||||
-ldflags="-w -s -X main.version=${VERSION}" \
|
-ldflags="-w -s -X main.version=${VERSION}" \
|
||||||
-o /out/gateway ./cmd/gateway
|
-o /out/gateway ./cmd/gateway
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ resources:
|
|||||||
# kustomize edit set image forgejo.riotpiao.com/rock/api-gateway=:<sha>
|
# kustomize edit set image forgejo.riotpiao.com/rock/api-gateway=:<sha>
|
||||||
images:
|
images:
|
||||||
- name: forgejo.riotpiao.com/rock/api-gateway
|
- name: forgejo.riotpiao.com/rock/api-gateway
|
||||||
newTag: REPLACE_WITH_FIRST_BUILD_SHA
|
newTag: v0.0.0
|
||||||
|
|
||||||
commonLabels:
|
commonLabels:
|
||||||
app: api-gateway
|
app: api-gateway
|
||||||
|
|||||||
Reference in New Issue
Block a user