# BizGaze Support — server image
# Data store is PostgreSQL (DB_BACKEND=pg; the `pg` client is a prod dependency installed below). SQLite was
# retired 2026-08-12 — one schema source of truth (db/schema.pg.sql), no dual-maintenance drift.
FROM node:24-alpine

# ffmpeg: server-side video poster thumbnails (see static.js /thumbs/<id>). Small on Alpine.
RUN apk add --no-cache ffmpeg

ENV NODE_ENV=production
WORKDIR /app/server

# Install deps first for layer caching (only `ws`, plus optional nodemailer)
COPY server/package*.json ./
RUN npm install --omit=dev --no-audit --no-fund

# App source
COPY server/ ./

# Pre-deploy guard: FAIL the build if any inline <script> in the served HTML pages has a JS syntax error. A
# broken inline script takes down the whole page (one missing brace in home.html once caused an app-wide login
# outage). This turns that into a failed build instead of a production incident. See tools/check-syntax.js.
RUN node tools/check-syntax.js

# Served HTTP port (NPM terminates TLS and proxies here). The DB is Postgres (DATABASE_URL, set via .env);
# the /data volume holds uploads / recordings / transcripts / downloads (see docker-compose.yml).
ENV PORT=8090
EXPOSE 8090

CMD ["node", "server.js"]
