# Use an official Python runtime as a parent image FROM python:3.9-slim # Set the working directory in the container WORKDIR /app # Create cache directories with proper permissions RUN mkdir -p /tmp/transformers_cache /tmp/hf_home && \ chmod 777 /tmp/transformers_cache /tmp/hf_home # Set environment variables for transformers cache ENV TRANSFORMERS_CACHE=/tmp/transformers_cache ENV HF_HOME=/tmp/hf_home # Copy the requirements file and install dependencies first to leverage caching COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy all of your project files from the repository into the container COPY . . # Tell Docker that the container listens on port 7860 # Hugging Face Spaces expects applications to run on this port EXPOSE 7860 # --- CORRECTED COMMAND --- # This correctly points to the 'app' variable inside the 'app/main.py' file CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]