FROM python:3.12-slim

WORKDIR /app
COPY config/requirements.txt ./config/requirements.txt
RUN pip install --no-cache-dir -r ./config/requirements.txt \
    && groupadd --gid 10001 app \
    && useradd --uid 10001 --gid app --create-home --shell /usr/sbin/nologin app
COPY . /app

ENV HOME=/home/app \
    PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1
USER app:app
EXPOSE 5000
CMD ["gunicorn", "--config", "gunicorn.conf.py", "api:app"]
