# Use an official Python runtime as a parent image FROM python:3.10-slim # Set the working directory in the container WORKDIR /code # Set a writable cache directory for Hugging Face models ENV HF_HOME=/code/huggingface_cache ENV TRANSFORMERS_CACHE=/code/huggingface_cache # Copy the requirements file into the container at /code COPY ./requirements.txt /code/requirements.txt # Install any needed packages specified in requirements.txt RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt # Copy the rest of the application code into the container at /code COPY . /code/ # --- FIX: Change ownership of the app directory --- # The container runs as a non-root user (UID 1000) who needs permission to write to the cache. # This command gives that user ownership of the /code directory. RUN chown -R 1000:1000 /code # Expose the port the app will run on. Hugging Face Spaces uses 7860 by default. EXPOSE 7860 # Command to run the application using uvicorn CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]