omniapi / Dockerfile
banao-tech's picture
Update Dockerfile
f7e7a4c verified
raw
history blame
1.53 kB
# Base image with CUDA 12.2
FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04
# System dependencies
RUN apt-get update -q && \
apt-get install -y --no-install-recommends \
python3.9 \
python3-pip \
python-is-python3 \ # Ensures 'python' points to 'python3'
libgl1 \
libglib2.0-0 \
wget \
git \
&& rm -rf /var/lib/apt/lists/*
# CUDA/CuDNN setup with held packages override
RUN wget -qO /tmp/cuda-keyring.deb \
https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
dpkg -i /tmp/cuda-keyring.deb && \
apt-get update -q && \
apt-get install -y --allow-change-held-packages --no-install-recommends \
libcudnn8=8.9.5.29-1+cuda12.2 \
libcublas-12-2=12.2.5.6-1 \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Create directories for models and temporary files
RUN mkdir -p /app/weights/icon_detect /app/weights/icon_caption_florence /app/imgs \
&& chmod -R 777 /app # Ensure proper permissions
# Copy application code
COPY main.py utils.py download_models.py ./
# Download models during build
RUN python3 download_models.py # Use python3 explicitly
# Set up non-root user for Hugging Face Spaces
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]