File size: 1,210 Bytes
b0fe79f 3d65864 b0fe79f 3d65864 |
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 |
# Use Python 3.11 slim image for better compatibility with Hugging Face
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Set environment variables for Hugging Face Spaces
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PORT=7860
ENV HOST=0.0.0.0
# Install system dependencies required for the application
RUN apt-get update && apt-get install -y \
gcc \
g++ \
libffi-dev \
libssl-dev \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better Docker layer caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy only the main application file
COPY app.py .
# Create a simple health check script
RUN echo '#!/bin/bash\ncurl -f http://localhost:7860/health || exit 1' > /healthcheck.sh && \
chmod +x /healthcheck.sh
# Expose the port that Hugging Face expects
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD /healthcheck.sh
# Command to run the multi-model application
# Hugging Face Spaces expects the app to run on port 7860
CMD ["python", "app.py"] |