Spaces:
Sleeping
Sleeping
| FROM python:3.10-slim | |
| # Prevent Python from writing .pyc files and enable stdout/stderr flushing | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| # Set cache folder variables | |
| ENV HF_HOME=/app/hf_cache | |
| ENV TRANSFORMERS_CACHE=/app/hf_cache | |
| ENV XDG_CACHE_HOME=/app/hf_cache | |
| WORKDIR /app | |
| # Install system dependencies required for faiss and llama-cpp-python | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| cmake \ | |
| libomp-dev \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy and install Python dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip \ | |
| && pip install --no-cache-dir -r requirements.txt | |
| # Install mypy with mypyc support | |
| RUN pip install --no-cache-dir "mypy[mypyc]" pandas-stubs | |
| # Copy application code | |
| COPY . . | |
| # Make cache/vectorstore writable | |
| RUN mkdir -p /app/hf_cache /app/vectorstores && \ | |
| chmod -R 777 /app/hf_cache && \ | |
| chmod -R 777 /app/vectorstores | |
| # Compile performance-critical module(s) with mypyc using setup.py | |
| RUN python setup.py build_ext --inplace || true | |
| # Expose the HF Spaces port | |
| EXPOSE 7860 | |
| # Run the FastAPI app with uvicorn | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |
| # FROM python:3.10-slim | |
| # # Prevent Python from writing .pyc files and enable stdout/stderr flushing | |
| # ENV PYTHONDONTWRITEBYTECODE=1 | |
| # ENV PYTHONUNBUFFERED=1 | |
| # # Set cache folder variables | |
| # # --- We set the ENVs first --- | |
| # ENV HF_HOME=/app/hf_cache | |
| # ENV TRANSFORMERS_CACHE=/app/hf_cache | |
| # ENV XDG_CACHE_HOME=/app/hf_cache | |
| # WORKDIR /app | |
| # # Install system dependencies required for faiss and llama-cpp-python | |
| # RUN apt-get update && \ | |
| # apt-get install -y --no-install-recommends \ | |
| # build-essential \ | |
| # cmake \ | |
| # libomp-dev \ | |
| # git \ | |
| # && rm -rf /var/lib/apt/lists/* | |
| # # --- FIX 2: (Removes GPU flags for CPU free tier) --- | |
| # # ENV CMAKE_ARGS="-DLLAMA_CUBLAS=on" | |
| # # ENV FORCE_CMAKE=1 | |
| # # Copy and install Python dependencies | |
| # COPY requirements.txt . | |
| # RUN pip install --no-cache-dir --upgrade pip \ | |
| # && pip install --no-cache-dir -r requirements.txt | |
| # # Copy application code | |
| # COPY . . | |
| # # --- FIX 1 & 3: (Solves PermissionErrors for cache and vectorstores) --- | |
| # # Create all app-writable dirs AND set their permissions *after* COPY . . | |
| # # This ensures that even if local dirs are copied over, | |
| # # their permissions are corrected to be writable by all users. | |
| # RUN mkdir -p /app/hf_cache /app/vectorstores && \ | |
| # chmod -R 777 /app/hf_cache && \ | |
| # chmod -R 777 /app/vectorstores | |
| # # Expose the HF Spaces port | |
| # EXPOSE 7860 | |
| # # Run the FastAPI app with uvicorn | |
| # CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |