File size: 1,352 Bytes
29b4491 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # Dockerfile for Hugging Face Spaces
# Multi-service: Streamlit UI + Flask MCP API with nginx reverse proxy
# All traffic goes through port 7860:
# https://your-space.hf.space/ → Streamlit UI
# https://your-space.hf.space/mcp/* → Flask MCP API
FROM python:3.10-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
nginx \
supervisor \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy and install Python dependencies
COPY requirements-hf.txt .
RUN pip install --no-cache-dir -r requirements-hf.txt
# Copy application files
COPY streamlit.py .
COPY mcp_flask_server.py .
COPY web ./web
# Configure nginx
COPY nginx.conf /etc/nginx/sites-available/default
RUN rm -f /etc/nginx/sites-enabled/default && \
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/
# Configure supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Create log directory
RUN mkdir -p /var/log/supervisor
# Expose only port 7860 (HF Spaces requirement)
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl --fail http://localhost:7860/ || exit 1
# Start supervisor to manage all services
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|