replcitae / Dockerfile
Samfy001's picture
Update Dockerfile
3d65864 verified
# 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"]