Spaces:
Sleeping
Sleeping
| FROM python:3.10-slim | |
| # Set environment variables, pointing cache to a writable directory inside /app | |
| ENV PYTHONUNBUFFERED=1 \ | |
| DEBIAN_FRONTEND=noninteractive \ | |
| TZ=UTC \ | |
| HF_HOME=/app/data/.huggingface | |
| # Create a non-root user and grant permissions | |
| RUN useradd -m -u 1000 user | |
| # Create and set working directory | |
| WORKDIR /app | |
| # Create a writable directory for cache and give ownership to the user | |
| RUN mkdir -p /app/data && chown -R user:user /app/data | |
| # Copy requirements first to leverage Docker cache | |
| COPY --chown=user:user requirements.txt . | |
| # Switch to the non-root user before installing dependencies | |
| USER user | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the application source code as the user | |
| COPY --chown=user:user ./src ./src | |
| # Expose the port the app runs on | |
| EXPOSE 7860 | |
| # Set the command to run the application | |
| CMD ["python", "src/app.py"] |