32 lines
971 B
Docker
32 lines
971 B
Docker
# redapricot Go client image.
|
|
#
|
|
# Build from the repository root (the Go module lives here):
|
|
# docker build -t redapricot-client .
|
|
#
|
|
# Run with a mounted config:
|
|
# docker run --rm -v "$PWD/client.json:/etc/redapricot/client.json" \
|
|
# redapricot-client /etc/redapricot/client.json
|
|
#
|
|
# syntax=docker/dockerfile:1
|
|
|
|
# ---- build stage ----
|
|
FROM golang:1.25 AS build
|
|
WORKDIR /src
|
|
|
|
# Cache module downloads separately from the source.
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# Build a static, stripped binary.
|
|
COPY . .
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \
|
|
-o /out/redapricot-client ./cmd/redapricot-client
|
|
|
|
# ---- runtime stage ----
|
|
FROM gcr.io/distroless/static:nonroot
|
|
COPY --from=build /out/redapricot-client /usr/local/bin/redapricot-client
|
|
USER nonroot:nonroot
|
|
ENTRYPOINT ["/usr/local/bin/redapricot-client"]
|
|
# Default config path; override by passing a different path as the container arg.
|
|
CMD ["/etc/redapricot/client.json"]
|