FROM golang:1.25-alpine AS builder

RUN apk add --no-cache git

WORKDIR /build

COPY go-wst/ go-wst/
COPY juwan-backend/go.mod juwan-backend/go.sum juwan-backend/
WORKDIR /build/juwan-backend
RUN go mod download

COPY juwan-backend/ /build/juwan-backend/
RUN CGO_ENABLED=0 go build -o /chat-rpc ./app/chat/rpc/

FROM alpine:latest
COPY --from=builder /chat-rpc /chat-rpc
COPY juwan-backend/app/chat/rpc/etc/pb.yaml /etc/pb.yaml
CMD ["/chat-rpc", "-f", "/etc/pb.yaml"]
