# Use an official Python runtime as a parent image FROM python:3.11-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ FLASK_APP=app.py \ HOME=/home/user # Create a non-root user RUN useradd -m -u 1000 user USER user WORKDIR $HOME/app # Copy requirements and install COPY --chown=user requirement.txt . RUN pip install --no-cache-dir --user -r requirement.txt # Add user bin to path ENV PATH="/home/user/.local/bin:${PATH}" # Copy the rest of the application COPY --chown=user . . # Hugging Face Spaces required port EXPOSE 7860 # Launch the app CMD ["python", "app.py"]