# Use an official Python runtime as a parent image FROM python:3.9-slim # Set the working directory in the container WORKDIR /app # Copy the entire project directory into the container at /app COPY . /app # Install basic dependencies (as per your instructions) RUN pip install --no-cache-dir torch flask numpy uvicorn # Install the local transformers package # We point to the ./transformers directory relative to the root RUN pip install -e './transformers[torch]' --no-build-isolation # Create a non-root user to run the application (Recommended for HF Spaces security) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Expose the port that Hugging Face Spaces expects (7860) EXPOSE 7860 # Command to run the application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--interface", "wsgi", "--log-level", "debug"]