FROM python:3.11-slim-bookworm

RUN apt-get update \
    && apt-get install -y --no-install-recommends ffmpeg \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app ./app
COPY static ./static
COPY config/launch-gates.example.json ./config/launch-gates.example.json
COPY docs ./docs

RUN useradd --create-home --uid 1000 vaani \
    && mkdir -p /app/data /app/config \
    && chown -R vaani:vaani /app
USER vaani

ENV VAANI_HOST=0.0.0.0 \
    VAANI_PORT=8765 \
    VAANI_DATA_DIR=/app/data \
    PYTHONUNBUFFERED=1 \
    PYTHONIOENCODING=utf-8

EXPOSE 8765
CMD ["python", "-m", "app"]
