Spaces:
Sleeping
Sleeping
| FROM python:3.11-slim | |
| # Create the same UID (1000) that Hugging Face Spaces uses | |
| RUN useradd -m -u 1000 user | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| git \ | |
| build-essential \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set working directory | |
| WORKDIR /home/user/app | |
| # Copy requirements and install Python dependencies | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Install Playwright and chromium browser | |
| RUN pip install --no-cache-dir playwright && \ | |
| playwright install chromium && \ | |
| playwright install-deps chromium | |
| # Copy the rest of the application | |
| COPY --chown=user . . | |
| # Create directories that need write permissions | |
| RUN mkdir -p logs generated_repos && \ | |
| chown -R user:user logs generated_repos | |
| # Switch to non-root user | |
| USER user | |
| # Set environment variables | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PYTHONUNBUFFERED=1 | |
| # Expose the port that Hugging Face Spaces expects | |
| EXPOSE 7860 | |
| # Start the student API (this is what students will deploy) | |
| CMD ["uvicorn", "student.api:app", "--host", "0.0.0.0", "--port", "7860"] | |