Files
mqqt-scrubber/Dockerfile
2026-03-12 18:51:32 +01:00

31 lines
948 B
Docker

FROM golang:1.24-alpine AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY cmd ./cmd
COPY internal ./internal
COPY config.example.json ./config.example.json
RUN test -f ./cmd/mqqt-scrubber/main.go || (echo "cmd/mqqt-scrubber/main.go is missing from the Docker build context; verify the checkout, sparse-checkout settings, and build context path" >&2; exit 1)
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/mqqt-scrubber ./cmd/mqqt-scrubber
FROM alpine:3.20
RUN addgroup -S app && adduser -S -G app app \
&& apk add --no-cache ca-certificates wget
WORKDIR /app
COPY --from=build /out/mqqt-scrubber /usr/local/bin/mqqt-scrubber
COPY config.example.json /app/config.json
USER app
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 CMD wget -q -O- http://127.0.0.1:8080/healthz >/dev/null || exit 1
ENTRYPOINT ["/usr/local/bin/mqqt-scrubber"]
CMD ["-config", "/app/config.json"]