From 8808cfc78a0b1aded6b8a2e6021b04f415790022 Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sat, 18 Jul 2026 19:45:29 +0200 Subject: [PATCH 1/8] Add Dockerfile and .dockerignore for containerization --- .dockerignore | 24 ++++++++++++++++++++++++ Dockerfile | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..1a88af57 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,24 @@ +.git +__pycache__ +*.pyc +*.pyo +.ipynb_checkpoints +.eggs +*.egg-info +dist +build +.venv +venv +.env +*.pt +*.pth +*.bin +*.onnx +output +outputs +wandb +.ml-cache +.mypy_cache +.pytest_cache +.ruff_cache +.pre-commit-cache diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c2f95b76 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 + +ENV DEBIAN_FRONTEND=noninteractive +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3.11 \ + python3.11-dev \ + python3.11-venv \ + python3-pip \ + git \ + git-lfs \ + ffmpeg \ + cmake \ + ninja-build \ + libgl1-mesa-glx \ + libglib2.0-0 \ + && ln -sf /usr/bin/python3.11 /usr/bin/python \ + && ln -sf /usr/bin/python3.11 /usr/bin/python3 \ + && rm -rf /var/lib/apt/lists/* + +ENV CUDA_HOME=/usr/local/cuda +ENV PATH="${CUDA_HOME}/bin:${PATH}" +ENV LD_LIBRARY_PATH="${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}" + +RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel + +WORKDIR /app + +COPY pyproject.toml README.md ./ +COPY src/ src/ + +RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cu124 + +RUN pip install --no-cache-dir xformers --index-url https://download.pytorch.org/whl/cu124 + +RUN pip install --no-cache-dir -e ".[all]" --no-build-isolation + +EXPOSE 7860 + +ENTRYPOINT ["da3"] +CMD ["gradio"] From 1d2b7b79b6cfeb24f303a4233241da9f2586c90d Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sat, 18 Jul 2026 19:46:54 +0200 Subject: [PATCH 2/8] Add GitHub Actions workflow for building and pushing Docker images --- .github/workflows/docker-build.yml | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 00000000..8b7b6aba --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,53 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Container Registry + if: github.event_name == 'push' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name == 'push' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max From c241220f877c7620be4b064e5dabcf5a7e307ec0 Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sat, 18 Jul 2026 19:47:51 +0200 Subject: [PATCH 3/8] temporarily enable in the branch: add-docker --- .github/workflows/docker-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 8b7b6aba..5c7aadd0 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - add-docker env: REGISTRY: ghcr.io From a6fefe6d032a5411a5cc4061945c93d6aafe140c Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sat, 18 Jul 2026 19:52:14 +0200 Subject: [PATCH 4/8] Fix: pip._vendor.pyproject_hooks._impl.BackendUnavailable: Cannot import 'hatchling.build' --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c2f95b76..051a3865 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,8 @@ RUN pip install --no-cache-dir torch torchvision --index-url https://download.py RUN pip install --no-cache-dir xformers --index-url https://download.pytorch.org/whl/cu124 -RUN pip install --no-cache-dir -e ".[all]" --no-build-isolation +RUN pip install --no-cache-dir hatchling hatch-vcs && \ + pip install --no-cache-dir -e ".[all]" --no-build-isolation EXPOSE 7860 From d6c2bd40d6602e8f589af9e8157e52bbc239f72d Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sat, 18 Jul 2026 19:56:49 +0200 Subject: [PATCH 5/8] fix: Add editables --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 051a3865..b00656e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,7 @@ RUN pip install --no-cache-dir torch torchvision --index-url https://download.py RUN pip install --no-cache-dir xformers --index-url https://download.pytorch.org/whl/cu124 -RUN pip install --no-cache-dir hatchling hatch-vcs && \ +RUN pip install --no-cache-dir hatchling hatch-vcs editables && \ pip install --no-cache-dir -e ".[all]" --no-build-isolation EXPOSE 7860 From 25dceb668b20681a411ff95f46b67cf205c7d068 Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sat, 18 Jul 2026 20:04:59 +0200 Subject: [PATCH 6/8] add: TORCH_CUDA_ARCH_LIST --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index b00656e9..dd70ae06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,8 @@ RUN pip install --no-cache-dir torch torchvision --index-url https://download.py RUN pip install --no-cache-dir xformers --index-url https://download.pytorch.org/whl/cu124 +ENV TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;8.9;9.0" + RUN pip install --no-cache-dir hatchling hatch-vcs editables && \ pip install --no-cache-dir -e ".[all]" --no-build-isolation From ed9a8813c0ed13ea630d1e70bb72fab785701f61 Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sun, 19 Jul 2026 16:26:27 +0200 Subject: [PATCH 7/8] add docker compose configuration for da3-backend service --- compose.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 compose.yml diff --git a/compose.yml b/compose.yml new file mode 100644 index 00000000..f438a15e --- /dev/null +++ b/compose.yml @@ -0,0 +1,23 @@ +services: + # Use: docker exec -it da3-backend bash + # To create a bash session inside the container to run commands like: da3 auto --use-backend --backend-url http://localhost:7860 --export-dir workspace/gallery/scene001 workspace/input + da3-backend: + container_name: da3-backend + image: ghcr.io/bytedance-seed/depth-anything-3:main + command: backend --model-dir depth-anything/DA3-LARGE-1.1 --port 7860 --host 0.0.0.0 --allow-unauthenticated + build: + dockerfile: Dockerfile + context: . + tty: true + stdin_open: true + ports: + - 7860:7860 + volumes: + - ./workspace:/app/workspace + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all # To use specifics GPUs --> device_ids: ['0'] + capabilities: [ gpu ] From 1cef4adc8df70ce7d35c636f838a8b5eb728a13f Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sun, 19 Jul 2026 22:08:01 +0200 Subject: [PATCH 8/8] Save the models in ./models to prevent re-download on every docker compose run --- .dockerignore | 1 + .gitignore | 3 +++ compose.yml | 1 + 3 files changed, 5 insertions(+) diff --git a/.dockerignore b/.dockerignore index 1a88af57..3dc08032 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ +models/ .git __pycache__ *.pyc diff --git a/.gitignore b/.gitignore index 61cce29d..bcbd6076 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Docker +models/ + # Python cache __pycache__/ *.py[cod] diff --git a/compose.yml b/compose.yml index f438a15e..ab510572 100644 --- a/compose.yml +++ b/compose.yml @@ -14,6 +14,7 @@ services: - 7860:7860 volumes: - ./workspace:/app/workspace + - ./models:/root/.cache/huggingface/hub deploy: resources: reservations: