Rename Dockerfile to docker/Dockerfile.prod
Browse files- Dockerfile +0 -79
- docker/Dockerfile.prod +47 -0
Dockerfile
DELETED
|
@@ -1,79 +0,0 @@
|
|
| 1 |
-
# ============================================================================
|
| 2 |
-
# MatAnyOne + SAM2 + Gradio Dockerfile (Python 3.10 + CUDA 12.1)
|
| 3 |
-
# ============================================================================
|
| 4 |
-
|
| 5 |
-
# Use NVIDIA CUDA 12.1 base image with Python 3.10
|
| 6 |
-
FROM nvidia/cuda:12.1.0-cudnn8-runtime-ubuntu20.04
|
| 7 |
-
|
| 8 |
-
# Environment settings
|
| 9 |
-
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 10 |
-
PYTHONUNBUFFERED=1 \
|
| 11 |
-
DEBIAN_FRONTEND=noninteractive
|
| 12 |
-
|
| 13 |
-
# Install Python 3.10 and system dependencies
|
| 14 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 15 |
-
python3.10 python3.10-dev python3-pip python3.10-venv \
|
| 16 |
-
git wget curl build-essential cmake pkg-config \
|
| 17 |
-
ffmpeg libsm6 libxext6 libfontconfig1 libxrender1 \
|
| 18 |
-
libgl1-mesa-glx libglib2.0-0 \
|
| 19 |
-
libavformat-dev libavcodec-dev libavdevice-dev \
|
| 20 |
-
libavutil-dev libswscale-dev libswresample-dev libavfilter-dev \
|
| 21 |
-
&& apt-get clean \
|
| 22 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 23 |
-
|
| 24 |
-
# Create working directory
|
| 25 |
-
WORKDIR /app
|
| 26 |
-
|
| 27 |
-
# Create non-root user
|
| 28 |
-
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
|
| 29 |
-
USER appuser
|
| 30 |
-
|
| 31 |
-
# Upgrade pip and install wheel
|
| 32 |
-
RUN python3.10 -m pip install --no-cache-dir --user pip setuptools wheel
|
| 33 |
-
|
| 34 |
-
# Copy requirements for layer caching
|
| 35 |
-
COPY --chown=appuser:appuser requirements.txt .
|
| 36 |
-
|
| 37 |
-
# Install PyTorch (CUDA 12.1 build)
|
| 38 |
-
RUN python3.10 -m pip install --no-cache-dir --user \
|
| 39 |
-
torch==2.1.0 \
|
| 40 |
-
torchvision==0.16.0 \
|
| 41 |
-
torchaudio==2.1.0 \
|
| 42 |
-
--extra-index-url https://download.pytorch.org/whl/cu121
|
| 43 |
-
|
| 44 |
-
# Install core CV/scientific dependencies
|
| 45 |
-
RUN python3.10 -m pip install --no-cache-dir --user \
|
| 46 |
-
numpy==1.26.4 \
|
| 47 |
-
opencv-python-headless==4.10.0.84 \
|
| 48 |
-
Pillow>=10.0.1,<11.0 \
|
| 49 |
-
scipy==1.13.1 \
|
| 50 |
-
av==12.1.0
|
| 51 |
-
|
| 52 |
-
# Install everything else from requirements.txt
|
| 53 |
-
RUN python3.10 -m pip install --no-cache-dir --user -r requirements.txt
|
| 54 |
-
|
| 55 |
-
# Add user bin to PATH
|
| 56 |
-
ENV PATH="/home/appuser/.local/bin:$PATH"
|
| 57 |
-
|
| 58 |
-
# Copy application code
|
| 59 |
-
COPY --chown=appuser:appuser . .
|
| 60 |
-
|
| 61 |
-
# Create runtime directories
|
| 62 |
-
RUN mkdir -p /tmp/model_cache /tmp/processing /tmp/jobs && \
|
| 63 |
-
chmod 755 /tmp/model_cache /tmp/processing /tmp/jobs
|
| 64 |
-
|
| 65 |
-
# Runtime environment variables
|
| 66 |
-
ENV GRADIO_SERVER_NAME="0.0.0.0" \
|
| 67 |
-
GRADIO_SERVER_PORT="7860" \
|
| 68 |
-
MODEL_CACHE_DIR="/tmp/model_cache" \
|
| 69 |
-
TORCH_HOME="/tmp/model_cache"
|
| 70 |
-
|
| 71 |
-
# Health check
|
| 72 |
-
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
| 73 |
-
CMD curl -f http://localhost:7860/ || exit 1
|
| 74 |
-
|
| 75 |
-
# Expose Gradio port
|
| 76 |
-
EXPOSE 7860
|
| 77 |
-
|
| 78 |
-
# Run application
|
| 79 |
-
CMD ["python3.10", "app.py"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docker/Dockerfile.prod
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
# Main application with GPU support
|
| 5 |
+
backgroundfx-gpu:
|
| 6 |
+
build:
|
| 7 |
+
context: ..
|
| 8 |
+
dockerfile: docker/Dockerfile
|
| 9 |
+
image: backgroundfx-pro:gpu
|
| 10 |
+
container_name: backgroundfx-gpu
|
| 11 |
+
runtime: nvidia
|
| 12 |
+
environment:
|
| 13 |
+
- NVIDIA_VISIBLE_DEVICES=0
|
| 14 |
+
- CUDA_VISIBLE_DEVICES=0
|
| 15 |
+
- GRADIO_SERVER_NAME=0.0.0.0
|
| 16 |
+
- GRADIO_SERVER_PORT=7860
|
| 17 |
+
- MODEL_CACHE_DIR=/app/models
|
| 18 |
+
- TORCH_HOME=/app/models/.cache
|
| 19 |
+
- LOG_LEVEL=INFO
|
| 20 |
+
- MAX_WORKERS=4
|
| 21 |
+
volumes:
|
| 22 |
+
- model-cache:/app/models
|
| 23 |
+
- uploads:/app/uploads
|
| 24 |
+
- outputs:/app/outputs
|
| 25 |
+
- ./config:/app/config:ro
|
| 26 |
+
ports:
|
| 27 |
+
- "7860:7860" # Gradio UI
|
| 28 |
+
- "8000:8000" # REST API
|
| 29 |
+
networks:
|
| 30 |
+
- backgroundfx-net
|
| 31 |
+
healthcheck:
|
| 32 |
+
test: ["CMD", "curl", "-f", "http://localhost:7860/health"]
|
| 33 |
+
interval: 30s
|
| 34 |
+
timeout: 10s
|
| 35 |
+
retries: 3
|
| 36 |
+
start_period: 60s
|
| 37 |
+
deploy:
|
| 38 |
+
resources:
|
| 39 |
+
reservations:
|
| 40 |
+
devices:
|
| 41 |
+
- driver: nvidia
|
| 42 |
+
count: 1
|
| 43 |
+
capabilities: [gpu]
|
| 44 |
+
limits:
|
| 45 |
+
memory: 16G
|
| 46 |
+
cpus: '8'
|
| 47 |
+
restart:
|