FROM python:3.9-slim # Create a non-root user and set environment variables RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Set working directory WORKDIR /app # Copy and install dependencies COPY --chown=user requirements.txt /app/requirements.txt RUN pip install --no-cache-dir -r /app/requirements.txt # Copy application files COPY --chown=user . /app # Command to run the Flask app CMD ["python", "app.py"]