# Builds the static TypeDoc HTML reference for @cognigy/rest-api-client
# and serves it with nginx. See .github/workflows/deploy-sdk-docs.yml.
#
# Build context is the repository root (not clients/rest): this package's
# src/shared/** is largely populated at dev time by bin/cognigy-link-shared
# symlinking in files from the root shared/ tree, so a clients/rest-only
# context leaves those imports unresolved. Run the real linking script
# instead of hand-copying its allowlist here, which is exactly the drift
# the script's own comments warn other Dockerfiles about.

FROM node:22 AS builder

WORKDIR /repo
COPY . .
RUN bash bin/cognigy-link-shared

WORKDIR /repo/clients/rest
RUN npm ci --ignore-scripts
RUN npm run docs

FROM nginx:alpine

# CVE-2026-111497: the base image still ships brotli-libs 1.2.0, fixed in 1.2.1.
RUN apk upgrade --no-cache brotli-libs

COPY --from=builder /repo/clients/rest/typedoc-html /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
