FROM python:3.9 # Create a non-root user RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" WORKDIR /app # Copy and install requirements first for caching COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the application COPY --chown=user . /app # Set the Flask app entry point for the 'flask run' command ENV FLASK_APP=flask_app.py # Run the Flask app on port 7860 (common for HF Spaces) and bind to all interfaces CMD ["python", "-m", "flask", "run", "--host", "0.0.0.0", "--port", "7860"]