Spaces:
Running
Running
File size: 746 Bytes
221c179 |
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 |
# Use Python 3.10 slim image for small footprint
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Create a non-root user (Required by Hugging Face Spaces)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Copy requirements first to leverage Docker cache
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the application code
COPY --chown=user . .
# Create a cache directory for the model so it's writable
RUN mkdir -p /home/user/.cache/huggingface && chmod -R 777 /home/user/.cache
# Expose the Hugging Face default port
EXPOSE 7860
# Start the FastAPI server
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |