Spaces:
Runtime error
Runtime error
FROM python:3.9 | |
ENV PYTHONUNBUFFERED=1 | |
WORKDIR /code | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
git \ | |
curl \ | |
cmake \ | |
ninja-build \ | |
libopenblas-dev \ | |
&& useradd -m appuser \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Copy requirements first to leverage Docker cache | |
COPY app/requirements.txt . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the application code (excluding models) | |
COPY app /code/app | |
COPY app/main.py ./main.py | |
# Create models and cache directories and set correct ownership | |
RUN mkdir -p /code/models/.cache/huggingface && \ | |
chown -R appuser:appuser /code/models | |
# Set environment variables | |
ENV HOST=0.0.0.0 | |
ENV PORT=7860 | |
# Expose the FastAPI port | |
EXPOSE 7860 | |
# Switch to non-root user | |
USER appuser | |
# Command to run the FastAPI application | |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] |