# Use an official Python runtime as a parent image FROM python:3.9-slim-buster # Set the working directory in the container WORKDIR /app # Copy the current directory contents into the container at /app # This includes main.py, requirements.txt, and the models/ directory COPY . /app # Install any needed packages specified in requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Create a directory for your models if it doesn't exist # (though it should be copied from local) RUN mkdir -p models # Expose the port FastAPI will run on. Hugging Face Spaces often expects # port 7860 for web apps. EXPOSE 7860 # Command to run the Uvicorn server # The --host 0.0.0.0 makes the server accessible from outside the # container # The --port 7860 matches the EXPOSE instruction CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]