File size: 719 Bytes
8ad2128 | 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 | FROM python:3.11-slim
# Create a user to run the app (Hugging Face Spaces requirement)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Copy all files into the container
COPY --chown=user . $HOME/app
# Install dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Create a cache directory with proper permissions for Hugging Face transformers
ENV TRANSFORMERS_CACHE=$HOME/app/.cache
RUN mkdir -p $HOME/app/.cache
# Hugging Face Spaces require the app to run on port 7860
EXPOSE 7860
# Start the FastAPI application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|