FROM python:3.12-slim-bookworm

# unrar-free covers RAR4; for RAR5 archives replace with the non-free unrar:
#   RUN echo "deb http://deb.debian.org/debian bookworm non-free" >> /etc/apt/sources.list \
#    && apt-get update && apt-get install -y --no-install-recommends unrar
RUN apt-get update \
    && apt-get install -y --no-install-recommends unrar-free \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

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

COPY . .

# SQLite database and any persistent state live here; mount a volume in production
ENV DATA_DIR=/app/data
RUN mkdir -p /app/data

EXPOSE 8000

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
