Spaces:
Running
Running
| # Use an official Python runtime as a parent image | |
| FROM python:3.10-slim | |
| # Prevent Python from writing .pyc files and buffering stdout/stderr | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| WORKDIR /app | |
| # Install system dependencies (build essentials, git for huggingface hub, curl) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| git \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy only requirements first for better caching | |
| COPY requirements.txt /app/requirements.txt | |
| # Upgrade pip and install Python deps | |
| RUN python -m pip install --upgrade pip | |
| # (Assumes requirements.txt contains compatible pins; we enforce hf-hub here) | |
| RUN pip install -r /app/requirements.txt | |
| # Copy application code | |
| COPY . /app | |
| # Expose the port Gradio uses (Spaces uses 7860 by convention) | |
| EXPOSE 7860 | |
| # Use a non-root user for better security (optional) | |
| RUN adduser --disabled-password --gecos "" appuser && chown -R appuser /app | |
| USER appuser | |
| # Gradio launch its own server | |
| CMD ["python", "app.py"] | |