FROM python:3.10-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # Set work directory WORKDIR /app # Create instance directory with correct permissions RUN mkdir -p /app/instance && chmod 777 /app/instance # Install dependencies COPY requirements.txt /app/ RUN pip install --no-cache-dir -r requirements.txt # Copy project COPY . /app/ # Ensure all files are owned by user 1000 (HF default) RUN chown -R 1000:1000 /app # Switch to non-root user USER 1000 # Port for Hugging Face Spaces EXPOSE 7860 # Run the app CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]