Files
zeekayandHanzo Dev c16ed9fe26 Go 1.27.1, and the code it can say more simply
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]>
2026-09-17 02:34:35 -07:00

40 lines
1.8 KiB
Docker

# Self-contained multi-stage build of the Hanzo O11y OTel Collector.
#
# Unlike ./Dockerfile (which COPYs a binary the CI pre-build-command produced),
# this compiles the collector in-image, so an in-cluster Kaniko Job / platform
# build can produce the ZAP-enabled image WITHOUT GitHub Actions — the canonical
# Hanzo build path when the reusable GH workflow is unavailable.
#
# Build (Kaniko, in-cluster):
# /kaniko/executor \
# --context git://github.com/hanzoai/otel-collector.git#refs/heads/feat/zap-native-otel \
# --dockerfile cmd/o11yotelcollector/Dockerfile.selfbuild \
# --destination ghcr.io/hanzoai/otel-collector:zap-native \
# --build-arg TARGETARCH=amd64
FROM golang:1.27.1-bookworm AS build
WORKDIR /src
# Prime the module cache first for better layer reuse.
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG TARGETOS=linux
ARG TARGETARCH=amd64
# Gate the ZAP surface (the receiver+exporter this distro adds over upstream) in
# the build itself — the canonical CI runs `test:` on a bare arc runner with no
# Go toolchain and a DinD daemon (bind-mounts don't cross), so the test lives
# here where the toolchain + source already are. A failing test fails the image.
RUN CGO_ENABLED=0 go test ./receiver/zapreceiver/... ./exporter/zapexporter/...
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -trimpath -o /out/hanzo-otel-collector ./cmd/o11yotelcollector
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
ARG USER_UID=10001
USER ${USER_UID}
COPY --from=build /out/hanzo-otel-collector /hanzo-otel-collector
COPY conf/default.yaml /etc/otel/config.yaml
# 4317 OTLP-gRPC, 4318 OTLP-HTTP (interop) + 4319 ZAP-native (canonical Hanzo).
EXPOSE 4317 4318 4319
ENTRYPOINT [ "/hanzo-otel-collector" ]
CMD ["--config", "/etc/otel/config.yaml"]