FROM python:3.12-slim-bookworm

RUN apt-get update \
    && apt-get install -y --no-install-recommends ffmpeg 7zip git ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# unrpyc v2 decompiles .rpyc from Ren'Py 6.18 – 8 on Python 3
ARG UNRPYC_REF=master
RUN git clone --depth 1 --branch ${UNRPYC_REF} https://github.com/CensoredUsername/unrpyc /opt/unrpyc \
    && rm -rf /opt/unrpyc/.git

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

ENV PYTHONUNBUFFERED=1 DATA_DIR=/data
CMD ["sh", "-c", "alembic upgrade head && exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --proxy-headers --forwarded-allow-ips='*'"]
