# See services/iam/Dockerfile for the build-stage pattern. This image
# additionally ships web/templates and web/static, since the gateway is
# the only service that renders HTML.
FROM golang:1.23-bookworm AS build
WORKDIR /src
COPY go.mod go.sum* ./
COPY gen/ gen/
COPY pkg/ pkg/
COPY services/gateway/ services/gateway/
RUN go mod tidy
RUN CGO_ENABLED=0 go build -o /out/gateway-server ./services/gateway/cmd/server

FROM gcr.io/distroless/static-debian12:nonroot
WORKDIR /app
COPY --from=build /out/gateway-server ./gateway-server
COPY --from=build /src/services/gateway/web ./web
ENV ENKLY_GATEWAY_HTTP_ADDR=:8080
ENV ENKLY_TEMPLATES_DIR=/app/web/templates
ENV ENKLY_STATIC_DIR=/app/web/static
EXPOSE 8080
ENTRYPOINT ["./gateway-server"]
