FROM python:3.9-slim WORKDIR /app # Install system dependencies if needed (e.g. for sqlite) # RUN apt-get update && apt-get install -y ... COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . # Ensure instance directory exists and is writable RUN mkdir -p instance && chmod 777 instance # Create a non-root user (recommended for Hugging Face Spaces) RUN useradd -m -u 1000 user # Switch to the new user USER user # Set home to the user's home directory ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Expose the port EXPOSE 7860 # Run the application CMD ["python", "app.py"]