# Stage 1: Build static Go binary FROM golang:1.26-alpine AS builder WORKDIR /src COPY go.mod ./ COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/rud . # Stage 2: Minimal Alpine runtime (supports HTTPS certs, ICMP ping, and /bin/sh custom checks) FROM alpine:3.20 RUN apk add --no-cache ca-certificates tzdata iputils-ping WORKDIR /app COPY --from=builder /out/rud /usr/local/bin/rud COPY rud.json /app/rud.json EXPOSE 8080 HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ CMD wget -q -O /dev/null http://127.0.0.1:8080/ || exit 1 ENTRYPOINT ["/usr/local/bin/rud"] CMD ["-config", "/app/rud.json"]