FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 WORKDIR /app # Install Python 3.10 and system dependencies for OpenCV RUN apt-get update && apt-get install -y --no-install-recommends \ python3 python3-pip \ libgl1 \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ && rm -rf /var/lib/apt/lists/* RUN ln -sf /usr/bin/python3 /usr/bin/python # Install PyTorch with CUDA 12.1 RUN pip install --no-cache-dir \ torch==2.5.1 torchvision==0.20.1 \ --index-url https://download.pytorch.org/whl/cu121 # Copy requirements and install COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Create logs and weights directories RUN mkdir -p logs weights model_code # Copy model code (read-only reference, never modified) COPY model_code/ /app/model_code/ # Copy weights COPY weights/ /app/weights/ # Copy application code COPY app.py . # Environment variables ENV MODEL_PORT=7005 ENV PRELOAD_MODEL=false ENV MODEL_TIMEOUT=1800 ENV WEIGHTS_PATH=/app/weights/pwtf_dvd_checkpoint.pth ENV MODEL_CODE_DIR=/app/model_code # Expose port EXPOSE 7005 # Drop root privileges RUN adduser --disabled-password --gecos '' appuser && \ chown -R appuser:appuser /app/logs /app/weights USER appuser # Run the service CMD ["python", "app.py"]