FROM node:22-alpine AS build

# The CI host uplink drops TLS 1.3 ClientHello carrying the hybrid
# X25519MLKEM768 key share; pin the npm stage to TLS 1.2 until that network
# defect is fixed. Certificates, SRI and the lockfile are unaffected.
ENV NODE_OPTIONS=--tls-max-v1.2

WORKDIR /app

COPY apps/ui/package.json apps/ui/package-lock.json ./
RUN npm ci

COPY apps/ui ./
COPY crank-community.png ./crank-community.png

RUN npm run build

FROM nginx:1.30.6-alpine3.24-slim

RUN apk add --no-cache --upgrade \
    'pcre2>=10.49-r0' \
    'libcrypto3>=3.5.8-r0' \
    'libssl3>=3.5.8-r0'

COPY apps/ui/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html

EXPOSE 3000
