mirror of
https://github.com/luxfi/bank.git
synced 2026-10-30 17:02:07 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
48 lines
2.4 KiB
Docker
48 lines
2.4 KiB
Docker
# Compile on the machine doing the building and emit for the target arch — the
|
|
# binary is pure Go (CGO_ENABLED=0), so cross-compiling is exact and a
|
|
# multi-arch build never pays to emulate the compiler.
|
|
FROM --platform=$BUILDPLATFORM golang:1.27.1-alpine AS builder
|
|
ENV GOTOOLCHAIN=auto
|
|
|
|
RUN apk add --no-cache gcc musl-dev git
|
|
|
|
# All modules resolve through the public Go proxy (GOPROXY default). Disable
|
|
# only the checksum DB — some luxfi tags were re-published, so sumdb would
|
|
# reject them; go.sum still enforces integrity. Do NOT set GOPRIVATE here: it
|
|
# would force direct git for luxfi/hanzoai modules, which needs credentials the
|
|
# container build doesn't have.
|
|
ENV GOSUMDB=off GOFLAGS=-mod=mod
|
|
|
|
WORKDIR /src
|
|
COPY go.mod go.sum ./
|
|
# First-party luxfi/hanzoai tags get periodically re-published, so the CI Go
|
|
# proxy serves a different module zip than the pinned go.sum (edge split-brain →
|
|
# "checksum mismatch / SECURITY ERROR"). Self-heal: attempt the download, and if
|
|
# a mismatch names a module, drop just that module's sum lines and retry (it gets
|
|
# re-recorded from the proxy under -mod=mod). Only re-published modules are
|
|
# touched — proxy-absent pins (e.g. genesis/pubsub) keep their valid sums. Fixes
|
|
# the whole recurring drift class in one place, however many tags drifted.
|
|
RUN set -e; for i in 1 2 3 4 5 6 7 8; do \
|
|
if out=$(go mod download 2>&1); then echo "go mod download ok"; break; fi; \
|
|
mod=$(printf '%s\n' "$out" | sed -n 's/^verifying \(.*\): checksum mismatch$/\1/p' | head -1); \
|
|
if [ -z "$mod" ]; then printf '%s\n' "$out"; exit 1; fi; \
|
|
path=${mod%@*}; ver=${mod#*@}; \
|
|
echo "drift: re-recording $path $ver from proxy"; \
|
|
sed -i "\|^$path $ver|d" go.sum; \
|
|
done
|
|
COPY . .
|
|
# Build offline against the module cache the step above populated. The proxy can
|
|
# serve inconsistent bytes for a re-published tag across requests, so re-fetching
|
|
# at build time would reintroduce the checksum mismatch; GOPROXY=off pins the
|
|
# build to the exact zips already downloaded + summed above.
|
|
# CGO_ENABLED=0 is how Base ships (pure-Go SQLite with math functions built in).
|
|
# With CGO=1 the linked SQLite lacks math functions and bankd fails at startup.
|
|
ARG TARGETARCH
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH GOPROXY=off go build -o /bankd ./cmd/bankd
|
|
|
|
FROM alpine:3.22
|
|
RUN apk add --no-cache ca-certificates
|
|
COPY --from=builder /bankd /usr/local/bin/bankd
|
|
EXPOSE 8070
|
|
ENTRYPOINT ["bankd", "serve", "--http", "0.0.0.0:8070"]
|