# Build context is the repo root (not this directory) — rule-engine-service
# depends on the sibling proto/ Go module via a relative `replace` directive.
FROM golang:1.25-alpine AS build
WORKDIR /src
COPY proto/ ./proto/
COPY services/rule-engine-service/ ./services/rule-engine-service/
WORKDIR /src/services/rule-engine-service
RUN go mod download
RUN CGO_ENABLED=0 go build -o /out/rule-engine-service ./cmd/rule-engine-service

FROM alpine:3.20
RUN adduser -D -u 10001 app
COPY --from=build /out/rule-engine-service /usr/local/bin/rule-engine-service
USER app
ENTRYPOINT ["/usr/local/bin/rule-engine-service"]
