68 lines
1.6 KiB
Docker
68 lines
1.6 KiB
Docker
# Base image: CUDA 11.8 runtime on Ubuntu 22.04
|
|
FROM nvidia/cuda:11.8.0-runtime-ubuntu22.04
|
|
|
|
# Avoid interactive prompts during build
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV TZ=Etc/UTC
|
|
|
|
# System dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
# Python
|
|
python3.10 \
|
|
python3.10-dev \
|
|
python3.10-venv \
|
|
python3-pip \
|
|
# FFmpeg
|
|
ffmpeg \
|
|
# OpenCV dependencies
|
|
libgl1-mesa-glx \
|
|
libglib2.0-0 \
|
|
libsm6 \
|
|
libxext6 \
|
|
libxrender-dev \
|
|
# Utilities
|
|
curl \
|
|
wget \
|
|
git \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user
|
|
RUN groupadd -g 1000 appuser && \
|
|
useradd -m -u 1000 -g appuser -s /bin/bash appuser
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p /scratch /models /data/training /data/output /logs
|
|
|
|
# Copy requirements first for better caching
|
|
COPY worker/requirements.txt /app/requirements.txt
|
|
|
|
# Create and activate virtual environment
|
|
RUN python3.10 -m venv /opt/venv
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
# Install Python dependencies
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY src/ /app/src/
|
|
COPY config.yaml /app/config.yaml
|
|
|
|
# Set environment variables
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
|
CMD python3 -c "import torch; assert torch.cuda.is_available()" || exit 1
|
|
|
|
# Switch to non-root user
|
|
USER appuser
|
|
|
|
# Default command
|
|
CMD ["python3", "-m", "src.main"]
|