# Empire merged app — single image serves all 11 verticals.
# Built on Microsoft's Playwright Python image so chromium + every system
# library it needs (libnss3, libatk1.0-0, libxkbcommon0, fonts, etc.) are
# already present. We layer ffmpeg + dejavu fonts on top for video/PDF work.

FROM mcr.microsoft.com/playwright/python:v1.49.0-jammy

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PIP_NO_CACHE_DIR=1

# System packages the app needs at runtime beyond what the base image ships:
#   ffmpeg              — actor takes, sizzle reel processing
#   fonts-dejavu-core   — deck PDF export glyph coverage
# Everything else (chromium + its 60-odd shared libs) comes from the base.
RUN apt-get update \
 && apt-get install -y --no-install-recommends \
        ffmpeg \
        fonts-dejavu-core \
 && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install Python deps first so they're cached when only app code changes.
COPY requirements.txt ./
RUN pip install -r requirements.txt

# Playwright browsers are baked into the base image, but a fresh `install`
# call is cheap and guarantees the chromium binary the SDK expects is
# discoverable from the app's Python env.
RUN python -m playwright install chromium

COPY . .

# Render sets $PORT at runtime; default to 8000 for local docker builds.
ENV PORT=8000
EXPOSE 8000

CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT}"]
