CoolFace
Apppublic

algoryn/validation

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
Dockerfile59 linesDownload Raw Back to root
1# Use Python 3.12 as base image2FROM python:3.12-slim3 4# Install system dependencies including OpenCV requirements5RUN apt-get update && apt-get install -y \6    curl \7    libgl1 \8    libglib2.0-0 \9    libsm6 \10    libxext6 \11    libxrender1 \12    libgomp1 \13    && rm -rf /var/lib/apt/lists/*14 15# Set up a new user named "user" with user ID 1000 (HF Spaces requirement)16RUN useradd -m -u 1000 user17 18# Switch to the "user" user19USER user20 21# Set home to the user's home directory22ENV HOME=/home/user \23    PATH=/home/user/.local/bin:$PATH24 25# Set the working directory to the user's home directory26WORKDIR $HOME/app27 28# Upgrade pip and install dependencies29RUN pip install --no-cache-dir --upgrade pip30 31# Copy requirements first for better Docker layer caching32# Note: For HF Spaces deployment, files are in root. For local builds, adjust paths as needed.33COPY --chown=user requirements.txt $HOME/app/34 35# Install Python dependencies36RUN pip install --no-cache-dir --user -r requirements.txt37 38# Copy the source code39# Note: For HF Spaces, files are synced to root directory40COPY --chown=user src/ $HOME/app/src/41COPY --chown=user models/ $HOME/app/models/42 43# Copy the main entry point44COPY --chown=user main.py $HOME/app/45 46# Expose the port that the app runs on (HF Spaces default is 7860)47EXPOSE 786048 49# Set environment variables50ENV PYTHONPATH=$HOME/app51ENV PORT=786052 53# Health check to ensure the API is running54HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \55    CMD curl -f http://localhost:7860/health || exit 156 57# Start the application directly58CMD ["python", "main.py"]59