Spaces:
Sleeping
Sleeping
| FROM python:3.10-slim | |
| # Install system dependencies needed for OpenCV / PIL | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set up a new user 'user' with UID 1000 (Hugging Face default) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # Configure HF cache to be inside a writable directory | |
| ENV HF_HOME=/tmp/huggingface_cache | |
| WORKDIR /app | |
| # Copy requirements and install packages | |
| COPY --chown=user ./requirements.txt /app/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt | |
| RUN pip install --no-cache-dir accelerate | |
| # Copy all application code | |
| COPY --chown=user ./api /app/api | |
| COPY --chown=user ./app.py /app/app.py | |
| # Expose port 7860 | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # Command to run uvicorn | |
| CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"] | |