mirror of
https://github.com/hanzoai/kafka.git
synced 2026-10-30 14:48:25 +00:00
An empty image holding the static binary, the CA bundle and zoneinfo, and the directories it writes. Nothing else is present to run.
36 lines
1.2 KiB
Docker
36 lines
1.2 KiB
Docker
# syntax=docker/dockerfile:1
|
|
FROM --platform=$BUILDPLATFORM golang:1.26.5-alpine AS builder
|
|
# go.mod pins the toolchain. The golang base image sets GOTOOLCHAIN=local,
|
|
# which turns a `go` directive newer than the image into a hard build
|
|
# failure instead of a download.
|
|
ENV GOTOOLCHAIN=auto
|
|
|
|
ARG TARGETOS=linux
|
|
ARG TARGETARCH=amd64
|
|
|
|
RUN apk add --no-cache git
|
|
|
|
WORKDIR /src
|
|
COPY go.mod go.sum ./
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
go mod download
|
|
|
|
COPY . .
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-s -w" -o /hanzo-kafka .
|
|
|
|
# One directory in an empty image: the static binary and the files it reads;
|
|
# nothing else is present to run, so nothing else can be run.
|
|
FROM alpine:3.22 AS root
|
|
RUN apk add --no-cache ca-certificates tzdata
|
|
|
|
FROM scratch
|
|
COPY --from=root /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
|
COPY --from=root /usr/share/zoneinfo /usr/share/zoneinfo
|
|
COPY --from=builder /hanzo-kafka /usr/local/bin/hanzo-kafka
|
|
USER 65532:65532
|
|
EXPOSE 9092 9093
|
|
ENTRYPOINT ["/usr/local/bin/hanzo-kafka"]
|
|
CMD ["--pubsub-url", "nats://pubsub:4222", "--host", "0.0.0.0"]
|