Spaces:
Runtime error
Runtime error
Commit ·
fba31c1
1
Parent(s): 2e9afea
Fix requirements path in root Dockerfile
Browse files123456789101112131415161718192021222324252627282930313233343536# Use Python 3.10 slim as base imageFROM python:3.10-slim# Set working directory inside the containerWORKDIR /app# Set environment variables# Prevent Python from writing .pyc files to diskENV PYTHONDONTWRITEBYTECODE=1# Prevent Python from buffering stdout/stderrENV PYTHONUNBUFFERED=1# Set Hugging Face cache directory to a path inside /appENV HF_HOME=/app/.cache/huggingface# Install system dependencies required for building python extensions (like scikit-learn or chromadb if needed)RUN apt-get update && apt-get install -y --no-install-recommends \build-essential \&& rm -rf /var/lib/apt/lists/*# Copy requirements file first to leverage Docker cacheCOPY requirements.txt /app/# Install python dependenciesRUN pip install --no-cache-dir -r requirements.txt# Pre-download and cache the SentenceTransformer model during build timeRUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('BAAI/bge-large-en-v1.5')"# Copy the rest of the backend application codeCOPY . /app/# Expose the port FastAPI will run onEXPOSE 8000# Command to run the application using uvicornCMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]12345678910111213141516171819202122232425262728293031323334FROM python:3.10-slimWORKDIR /app# Set environment variablesENV PYTHONDONTWRITEBYTECODE=1ENV PYTHONUNBUFFERED=1ENV HF_HOME=/app/.cache/huggingface# Install system packages required for compiling libraries (like chromadb)RUN apt-get update && apt-get install -y --no-install-recommends \build-essential \&& rm -rf /var/lib/apt/lists/*# Copy requirements.txt from the server/ subdirectory (Crucial difference!)COPY server/requirements.txt /app/server/# Install Python dependenciesRUN pip install --no-cache-dir -r /app/server/requirements.txt# Pre-download and cache the SentenceTransformer model during build timeRUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('BAAI/bge-large-en-v1.5')"# Copy the entire project (both client/ and server/)COPY . /app/# Change working directory to server where main.py residesWORKDIR /app/server# Expose Hugging Face Spaces default portEXPOSE 7860# Run FastAPI using uvicorn on port 7860CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
Dockerfile+13-15