# Use Python 3.9 as base image (Compatible with torch/transformers) FROM python:3.9 # Set working directory WORKDIR /code # Copy requirements first to leverage Docker cache COPY ./requirements.txt /code/requirements.txt # Install dependencies (no-cache to keep image small) RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt # Create a clean directory structure for the app # Copy the app directory COPY ./app /code/app # Copy the data directory (Ensure writable) COPY ./data /code/data RUN chmod 777 /code/data # Copy the model (This will be large, ensure .dockerignore includes it if we were ignoring it, but here we need it) # Make sure the model path aligns with where your code expects it (in ../model relative to service) # Code expects: BASE_DIR/../../model -> /code/app/services/../../model -> /code/model COPY ./model /code/model # Expose port (Hugging Face Spaces uses 7860 by default) EXPOSE 7860 # Command to run the app # Note: We use port 7860 which is standard for HF Spaces CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]