# Multi-stage build for broad-announce services. # Stage 1: build the Go service binaries + loadgen + testfakes. # Stage 2: tiny alpine with just the binaries + ca-certs. FROM golang:1.25-alpine AS build WORKDIR /src # Cache deps COPY go.mod go.sum ./ COPY loadgen/go.mod ./loadgen/go.mod RUN go mod download # Build COPY . . RUN --mount=type=cache,target=/root/.cache/go-build \ CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \ -o /out/ingestd ./cmd/ingestd && \ CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \ -o /out/routerd ./cmd/routerd && \ CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \ -o /out/deliverd ./cmd/deliverd && \ CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \ -o /out/admind ./cmd/admind && \ CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \ -o /out/seed ./cmd/seed && \ cd loadgen && \ CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \ -o /out/loadgen-http ./cmd/http && \ cd .. && \ CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \ -o /out/fakefcmd ./testfakes/fakefcmd FROM alpine:3.20 RUN apk add --no-cache ca-certificates COPY --from=build /out/ /app/ # Default: print which binary to invoke; compose overrides command. CMD ["/app/ingestd"]