Spaces:
Sleeping
Sleeping
File size: 981 Bytes
e54458e e82d391 b18de50 e54458e e82d391 e54458e b18de50 e54458e e82d391 e54458e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# Use Python 3.9 as the base image
FROM python:3.9
# Set working directory in the container
WORKDIR /app
# Create a non-root user and set permissions
RUN useradd -m myuser && chown -R myuser:myuser /app
USER myuser
# Set Hugging Face cache directory
ENV HF_HOME=/app/.cache/huggingface
# Update PATH to include user’s local bin (where pip installs uvicorn)
ENV PATH="/home/myuser/.local/bin:${PATH}"
# Copy requirements.txt and install dependencies
COPY --chown=myuser:myuser requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Explicitly install uvicorn to ensure it’s available
RUN pip install --no-cache-dir uvicorn
# Pre-download the model to avoid runtime issues
RUN python -c "from transformers import pipeline; pipeline('text-classification', model='roberta-base-openai-detector')"
# Copy the application code
COPY --chown=myuser:myuser . .
# Run the FastAPI app with Uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |