FROM ubuntu:24.04 AS builder
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl gnupg \
    && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
    && apt-get install -y --no-install-recommends nodejs \
    && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --include=dev
COPY . .
RUN npm run build

FROM ubuntu:24.04
# python3+ffmpeg match the SHARED venv's Ubuntu 24.04 build, needed for
# BOT/render_replay.py (replay-canvas rendering, mounted at deploy time).
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl gnupg python3 ffmpeg \
    && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
    && apt-get install -y --no-install-recommends nodejs \
    && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY . .
COPY --from=builder /app/dist ./dist
EXPOSE 3010
CMD ["node", "server.cjs"]
