FROM golang:1.25-alpine AS builder

ARG VERSION=dev

WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" \
    -o mc-proxy ./cmd/mc-proxy

FROM alpine:3.21

RUN addgroup -S mc-proxy && adduser -S mc-proxy -G mc-proxy

COPY --from=builder /build/mc-proxy /usr/local/bin/mc-proxy

USER mc-proxy
ENTRYPOINT ["mc-proxy"]
CMD ["server", "--config", "/srv/mc-proxy/mc-proxy.toml"]
