Spaces:
Sleeping
Sleeping
File size: 886 Bytes
985c437 |
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 32 33 34 35 36 37 38 39 40 41 42 |
FROM python:3.9
ENV PYTHONUNBUFFERED=1
WORKDIR /code
# Install system dependencies
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 requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy all source code (app.py and related files)
COPY . /code
# Create models and cache directories and set correct ownership
RUN mkdir -p /code/models/.cache/huggingface && \
chown -R appuser:appuser /code
# 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
# Run the FastAPI app
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |