FROM golang:1.26-alpine AS build
WORKDIR /src

# The build context must include the indexer's input: the entire Einherjar
# repository. Build from the repo root with -f mcp/Dockerfile.
COPY . .

WORKDIR /src/mcp
RUN go mod download
RUN go run ./cmd/indexer /src
RUN CGO_ENABLED=0 go build -o /out/einherjar-mcp ./cmd/server

FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=build /out/einherjar-mcp /einherjar-mcp
EXPOSE 8080
ENTRYPOINT ["/einherjar-mcp"]
