Dockerfile 2.0 KB

12345678910111213141516171819202122
  1. # Multi-stage build for broad-announce services.
  2. # Stage 1: build the Go service binaries + loadgen + testfakes.
  3. # Stage 2: tiny alpine with just the binaries + ca-certs.
  4. FROM golang:1.25-alpine AS build
  5. WORKDIR /src
  6. # Cache deps
  7. COPY go.mod go.sum ./
  8. COPY loadgen/go.mod ./loadgen/go.mod
  9. RUN go mod download
  10. # Build
  11. COPY . .
  12. RUN go mod tidy
  13. 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-fcm ./cmd/deliverd-fcm && CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/deliverd-telegram ./cmd/deliverd-telegram && CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/deliverd-bench ./cmd/deliverd-bench && CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/telegramd ./cmd/telegramd && 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/archiverd ./cmd/archiverd && CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/authd ./cmd/authd && 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 && CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/loadgen-mqtt ./cmd/mqtt && CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/loadgen-grpc ./cmd/grpc && cd .. && CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/fakefcmd ./testfakes/fakefcmd && CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/faketgmd ./testfakes/faketgmd
  14. FROM alpine:3.20
  15. RUN apk add --no-cache ca-certificates
  16. COPY --from=build /out/ /app/
  17. # Default: print which binary to invoke; compose overrides command.
  18. CMD ["/app/ingestd"]