FROM golang:1.22 as builder

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

COPY cmd/ cmd/
COPY pkg/ pkg/
RUN CGO_ENABLED=0 GOOS=linux go build -o portal cmd/portal/main.go

FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/portal .
COPY pkg/web/portal/templates /templates
COPY pkg/web/portal/static /static

USER 65532:65532

ENTRYPOINT ["/portal"] 