# renderer — the finished-game image-render sidecar: Node + skia-canvas running the SAME
# ui/src/lib/gameimage.ts the web client unit-tests, bundled at build time (renderer/README.md).
# Debian slim, not the repo's usual alpine/distroless: skia-canvas ships prebuilt glibc
# binaries and resolves fonts through fontconfig, and the runtime fonts are baked into the
# image — Liberation Sans (the UI font stack's Linux face) + Noto Color Emoji (the 🏆).
FROM node:22-slim AS build
WORKDIR /src/renderer
RUN corepack enable && corepack prepare pnpm@11.0.9 --activate
COPY renderer/package.json renderer/pnpm-lock.yaml renderer/pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile
COPY renderer/build.mjs ./
COPY renderer/src ./src
COPY ui/src/lib /src/ui/src/lib
RUN pnpm run bundle

FROM node:22-slim
RUN apt-get update \
    && apt-get install -y --no-install-recommends fonts-liberation fonts-noto-color-emoji \
    && rm -rf /var/lib/apt/lists/*
ENV NODE_ENV=production
ARG VERSION=dev
ENV APP_VERSION=${VERSION}
WORKDIR /app
COPY --from=build /src/renderer/node_modules ./node_modules
COPY --from=build /src/renderer/dist ./dist
COPY renderer/src/server.mjs renderer/src/render.mjs renderer/src/offer.mjs renderer/src/legal.mjs ./src/
# The public legal pages: the owner-edited markdown, read once at boot. GET /offer/ also splices in
# the live price list fetched from the backend at request time; GET /privacy/ and GET /eula/ are
# static (no dynamic data).
COPY ui/legal/offer_ru.md ui/legal/privacy_ru.md ui/legal/eula_ru.md ./legal/
USER node
EXPOSE 8090
CMD ["node", "src/server.mjs"]
