Spaces:
Running
Running
File size: 1,127 Bytes
f3ca15e 327a3d3 f3ca15e 327a3d3 4a23019 f3ca15e 327a3d3 4a23019 327a3d3 c3483fa f3ca15e 327a3d3 f3ca15e 327a3d3 f3ca15e 327a3d3 f3ca15e 327a3d3 | 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 | # Use an official Python image
FROM python:3.10-slim
# Set standard Python environment variables for containerized apps
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Set the working directory
WORKDIR /api
# --- Cache Configuration ---
# Create a single, unified directory for all model caches.
# Make it fully writable to prevent "Permission Denied" errors when downloading models.
RUN mkdir -p /api/cache && chmod -R 777 /api/cache
# Tell all relevant libraries (Hugging Face, SentenceTransformers, PyTorch)
# to use this new writable directory. HF_HOME is the most important one.
ENV HF_HOME=/api/cache
ENV SENTENCE_TRANSFORMERS_HOME=/api/cache
ENV TORCH_HOME=/api/cache
# --- End Cache Configuration ---
# Install dependencies
# Copy only the requirements file first to leverage Docker layer caching
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# Copy the rest of the application code into the container
COPY . .
# Expose the port the app runs on
EXPOSE 7860
# Command to run the application
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"] |