Switch5 / Dockerfile
fred1012's picture
Upload 3 files
6393610 verified
FROM python:3.11-slim-bullseye
# Install system dependencies
RUN sed -i 's/main/main contrib non-free/' /etc/apt/sources.list && \
apt-get update && \
apt-get install -y --no-install-recommends \
unrar \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Upgrade pip and install core dependencies first
RUN pip install --no-cache-dir --upgrade pip setuptools wheel packaging
# Install CPU-only PyTorch first
# Copy requirements and install with special handling for flash_attn
COPY requirements.txt .
RUN pip install --no-cache-dir \
-r requirements.txt \
--find-links https://download.pytorch.org/whl/cpu \
--extra-index-url https://pypi.org/simple && \
# Install remaining packages that might have been skipped
pip install --no-cache-dir \
accelerate \
transformers==4.36.2 \
timm==0.9.12 \
einops==0.7.0
# Copy application code
COPY . .
# Create non-root user
RUN useradd -m -u 1000 user && \
chown -R user:user /app
USER user
# Environment variables to suppress warnings
ENV HF_HUB_DISABLE_PROGRESS=1
ENV TF_CPP_MIN_LOG_LEVEL=3
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]