EmoVIT / Dockerfile.multistage
manhteky123's picture
Upload 25 files
0028dd7 verified
FROM python:3.9-slim as base
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
wget \
curl \
build-essential \
libgl1-mesa-dev \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
libgcc-s1 \
ffmpeg \
libgtk-3-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Stage 2: Install dependencies
FROM base as dependencies
# Copy requirements
COPY requirements.txt .
# Install LAVIS first (it will handle its own dependencies)
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# Install dependencies in order to avoid conflicts
RUN pip install --no-cache-dir salesforce-lavis && \
pip install --no-cache-dir torch>=1.10.0 torchvision>=0.11.0 && \
pip install --no-cache-dir transformers>=4.28.0 && \
pip install --no-cache-dir Flask==2.3.3 gunicorn==21.2.0 && \
pip install --no-cache-dir pillow>=10.0.0 omegaconf>=2.3.0 && \
pip install --no-cache-dir pandas>=2.0.0 requests>=2.31.0 && \
pip install --no-cache-dir tqdm>=4.66.0 safetensors>=0.4.0 && \
pip install --no-cache-dir huggingface-hub>=0.20.0 && \
pip install --no-cache-dir einops>=0.7.0 timm>=0.4.12 && \
pip install --no-cache-dir sentencepiece>=0.1.99 && \
pip install --no-cache-dir loguru python-dotenv
# Stage 3: Final image
FROM dependencies as final
# Copy application code
COPY . .
# Create necessary directories
RUN mkdir -p static/css templates
# Set environment variables for Hugging Face Spaces
ENV PYTHONPATH=/app
ENV FLASK_APP=app.py
ENV FLASK_ENV=production
# Expose port for Hugging Face Spaces
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Command to run the application
CMD ["python", "app.py"]