# ── build stage ───────────────────────────────────────────────────────────────
FROM golang:1.26-alpine AS builder

WORKDIR /src

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /vecna ./cmd/vecna

# ── runtime stage ──────────────────────────────────────────────────────────────
FROM alpine:3.21

RUN apk add --no-cache ca-certificates

COPY --from=builder /vecna /usr/local/bin/vecna

ENV VECNA_CONFIG=/config/vecna.json

VOLUME ["/config"]

EXPOSE 8080

ENTRYPOINT ["vecna"]
CMD ["serve"]
