Spaces:
Sleeping
Sleeping
| FROM python:3.9-slim | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PORT=7860 \ | |
| TRANSFORMERS_CACHE=/tmp/huggingface | |
| # Set the working directory | |
| WORKDIR /code | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create cache directory with proper permissions | |
| RUN mkdir -p /tmp/huggingface && chmod 777 /tmp/huggingface | |
| # Install Python dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the application | |
| COPY ./app /code/app | |
| # Make port 7860 available | |
| EXPOSE 7860 | |
| # Create a non-root user and switch to it | |
| RUN adduser --disabled-password --gecos "" appuser && \ | |
| chown -R appuser:appuser /code /tmp/huggingface | |
| USER appuser | |
| # Run the application | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] |