# Use official Python slim image for a smaller footprint FROM python:3.12-slim # Set environment variables for security and performance ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 # Set working directory WORKDIR /app # Copy requirements.txt first for caching COPY requirements.txt . # Install dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the server code COPY app.py # Create a non-root user for security RUN useradd -m appuser && chown -R appuser:appuser /app USER appuser # Expose port 8000 EXPOSE 7860 # Command to run the server CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]