FROM python:3.12-slim

WORKDIR /app

# tzdata: python:3.12-slim doesn't include it by default, so the zoneinfo
# database backing the web UI's "Timezone" setting (used by "Quiet hours")
# would have no named zones to resolve without this -- ZoneInfo() would
# raise for anything other than "UTC".
#
# Node.js + fonts: whiteboard frame mode's render-service/ (own README
# there) runs as a second process in this same container rather than a
# separate compose service -- it's a lightweight, stateless, localhost-
# only sidecar with nothing worth independently scaling or restarting.
# NodeSource's setup script is used instead of Debian bookworm's own
# apt Node package, which is both older than jsdom's minimum (20.19+)
# and inconsistently available. fonts-dejavu-core gives the sidecar's
# SVG rasterizer something to render whiteboard text with.
RUN apt-get update && apt-get install -y --no-install-recommends \
    tzdata curl ca-certificates gnupg fontconfig fonts-dejavu-core \
    && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
    && apt-get install -y --no-install-recommends nodejs \
    && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY render-service ./render-service
RUN cd render-service && npm install --omit=dev

COPY app ./app
COPY start.sh .
RUN chmod +x start.sh

EXPOSE 8420

CMD ["./start.sh"]
