HF Spaces with Docker
HF Spaces also supports Docker β perfect for FastAPI or custom setups.
Create a Dockerfile in your Space repo:
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY app.py spam_model.pkl ./
ENV GRADIO_SERVER_NAME="0.0.0.0"
EXPOSE 7860
CMD ["python", "app.py"]
HuggingFace auto-detects the Dockerfile, builds the image, and deploys it.
This is how real ML apps get deployed β your Dockerfile becomes the deployment specification.