FROM python:3.12-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 WORKDIR /app # Install dependencies first for better layer caching before copying the rest of the code COPY requirements.txt . RUN python -m pip install --upgrade pip \ && pip install --no-cache-dir -r requirements.txt COPY . . # Create a non-root user for security RUN useradd -m appuser USER appuser # docs only for port app listens on EXPOSE 7860 CMD ["bash", "-lc", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860}"]