# syntax=docker/dockerfile:1
FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

WORKDIR /app

# Copy into /app/api/ (not /app/): `COPY api/ /app/` would flatten the directory
# contents into /app and `uvicorn api.app:app` would find no api package.
COPY api/requirements.txt /app/api/requirements.txt
RUN pip install --no-cache-dir -r /app/api/requirements.txt

COPY api/ /app/api/

# The /configs endpoints share the IMEI map validator with the listener, so
# the listener package is included too (validate_imei_map in
# listener/process.py is the single source of truth for both services).
COPY listener/ /app/listener/

# Run as an unprivileged user.
RUN useradd --system --create-home --uid 10001 appuser
USER appuser

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