File size: 860 Bytes
97d418a fd8b71c | 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 | # Dockerfile for Hugging Face Spaces deployment
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Copy requirements file
COPY requirements-hf.txt requirements.txt
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application files
COPY app.py .
COPY .env.example .env
# Expose Hugging Face Spaces default port
EXPOSE 7860
# Set environment variables for production
ENV PORT=7860
ENV DEBUG=False
ENV PYTHONUNBUFFERED=1
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:7860/health', timeout=5)" || exit 1
# Run the application with gunicorn
CMD ["gunicorn", "app:server", "--bind", "0.0.0.0:7860", "--workers", "2", "--threads", "4", "--timeout", "120", "--keep-alive", "5", "--log-level", "info"]
|