Files
zeekayandHanzo Dev 5e16b7230d Go 1.27.1, and the code it can say more simply
The module declares go 1.27.1 and the build image follows. go fix
applied the modernizers; omitzero is not applied, since it changes what
the JSON says.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-16 19:08:41 -07:00

48 lines
2.1 KiB
Docker

# syntax=docker/dockerfile:1
#
# ui-customization โ€” first Hanzo Base-native Go service binary.
# Single pure-Go binary: Base (embedded SQLite + vault) + typed ZAP router.
#
# CI builds this multi-arch (linux/amd64 + linux/arm64) on the hanzoai
# self-hosted runners โ†’ ghcr.io/hanzoai/ui-customization. Do NOT build locally.
#
# NOTE on go.mod replaces: the working-copy go.mod carries `replace` directives
# to ../base and ../../zap-proto/go for local dev while those modules' proxy
# availability is flaky. CI builds against the PUBLISHED modules โ€” the release
# pipeline drops the replaces (the modules resolve via GOPROXY) so this build
# context needs only this repo. If you must build with the replaces, use a
# monorepo build context that includes the sibling modules.
FROM golang:1.27.1-alpine AS builder
RUN apk add --no-cache git ca-certificates tzdata
WORKDIR /build
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod go mod download
COPY . .
# JSON v2 per SCALE_STANDARD.md ยง2: error/results bodies serialize via
# encoding/json; jsonv2 trims time + allocs on the hot path.
ARG GO_EXPERIMENT=jsonv2
ENV GOEXPERIMENT=${GO_EXPERIMENT}
# Pure-Go (CGO off): modernc SQLite + luxfi/zap need no C toolchain; the binary
# is statically linked and cross-compiles cleanly for both target arches.
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -trimpath \
-ldflags="-s -w" \
-o /build/ui-customization .
FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata curl \
&& addgroup -S hanzo && adduser -S hanzo -G hanzo
WORKDIR /app
COPY --from=builder /build/ui-customization /app/ui-customization
RUN mkdir -p /data /vaults && chown -R hanzo:hanzo /app /data /vaults
USER hanzo
# 8090 = Base sidecar HTTP (health/metrics); 9999 = typed ZAP capability RPC.
EXPOSE 8090 9999
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8090/healthz || exit 1
ENTRYPOINT ["/app/ui-customization"]
CMD ["serve", "--http=0.0.0.0:8090", "--zap=0.0.0.0:9999", "--dir=/data", "--vaultDir=/vaults"]