Skip to content

[Docker] Simplify and modernize Dockerfile#3290

Merged
MMathisLab merged 13 commits into
mainfrom
jaap/update_docker
May 19, 2026
Merged

[Docker] Simplify and modernize Dockerfile#3290
MMathisLab merged 13 commits into
mainfrom
jaap/update_docker

Conversation

@deruyter92

@deruyter92 deruyter92 commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

This PR is part 1 of updating the docker setup and only entails the Dockerfiles and how we build them. The deeplabcut-docker is also updated, but that is discussed separately in PR #3291 to avoid mixing topics.

adresses #3282, #3285

Motivation

  • Currently we have many dockerfiles with overlapping (or functionally identical) purpose. This PR replaces that with a single Dockerfile, which is easier to maintain and more transparent for users.
  • This PR simplifies the variety of image tags to a plain latest, latest-jupyter and 3.0rc14-core-cuda12.4 or similar.
    • cuda12.4 is kept as default which should run on basically most machines from the last 5 years (including newer ones thanks to backward compatibility).
    • Older DeepLabCut (pre-)releases remain on DockerHub with the appropriate tag.
    • <cudnn_version> is dropped from the name, since all were using the same.
    • base is dropped as image version since it is equivalent to core.
    • cuda 12.1 is dropped as default, and cuda11.8 will remain on DockerHub to support those with legacy hardware.
  • Images were not strictly matching the PyPI versions. This is changed in this PR for transparency.
  • Building docker images was done via (somewhat fragile) shell scripts. This PR replaces that with CI-friendly builds using Docker bake / buildx
  • The tools for Dockerfiles (targeting Docker users) and the deeplabcut-docker package (for deeplabcut-docker developers) was not clearly separated. The package is now moved to its own subdirectory.

Changes

  • Single multi-stage docker/Dockerfile: replaces separate Dockerfile.base / core / jupyter / test.
  • Versioned tags like {version}-core-cuda{CUDA} (no cudnn suffix in bake tags).
  • pip install "deeplabcut[modelzoo,wandb]==${DEEPLABCUT_VERSION}" instead of git main
  • Buildx bake defines core + jupyter, shared build-args
  • MARK_LATEST parameter to flag optional latest / latest-jupyter tag.
  • docker/docker-bake.hcl instead of docker/build.sh
  • move deeplabcut-docker package to its own subdirectory, separating it from the dockerfile logic.

Not included:

  • optional: add CI workflow for building docker images on release (should be easy to add now). Can be added in a separate PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the Docker build setup by consolidating multiple Dockerfiles into a single multi-stage docker/Dockerfile, replacing the legacy docker/build.sh matrix with a CI-friendly docker buildx bake configuration, and relocating the deeplabcut-docker helper package into docker/package/.

Changes:

  • Replace Dockerfile.base/core/jupyter/test with a single multi-stage docker/Dockerfile (core/jupyter/test stages).
  • Add docker/docker-bake.hcl to define reproducible build targets/tags (including optional latest tags via MARK_LATEST).
  • Move/add packaging scaffolding for deeplabcut-docker into docker/package/ and update Docker documentation accordingly.

Reviewed changes

Copilot reviewed 10 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
docker/package/setup.cfg Introduces setuptools packaging metadata + console entry point for deeplabcut-docker.
docker/package/pyproject.toml Defines build backend/requirements for the helper package.
docker/package/deeplabcut_docker.sh Adds shell launcher that pulls/builds user-mapped images and runs containers.
docker/package/deeplabcut_docker.py Adds Python CLI wrapper that spawns the shell launcher via a PTY.
docker/package/Makefile Updates README source path for PyPI packaging workflow.
docker/package/MANIFEST.in Ensures package artifacts (README/license/script) are included in builds.
docker/package/LICENSE Adds LGPLv3 license text for the helper package distribution.
docker/docker-bake.hcl Adds buildx bake targets for core + jupyter with versioned and optional latest tags.
docker/build.sh Removes legacy bash build/test/push matrix.
docker/README.md Updates docs for new tags and buildx bake workflow.
docker/Dockerfile.test Removes old dedicated test Dockerfile (replaced by multi-stage Dockerfile).
docker/Dockerfile.jupyter Removes old jupyter Dockerfile (replaced by multi-stage Dockerfile).
docker/Dockerfile.core Removes old core Dockerfile (replaced by multi-stage Dockerfile).
docker/Dockerfile.base Removes old base Dockerfile (replaced by multi-stage Dockerfile).
docker/Dockerfile Adds new multi-stage Dockerfile implementing core/jupyter/test stages.
docker/.dockerignore Adds docker build context ignore rules for a slimmer build context.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docker/Dockerfile Outdated
Comment thread docker/Dockerfile Outdated
Comment thread docker/README.md Outdated
deruyter92 and others added 3 commits April 21, 2026 17:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@C-Achard C-Achard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, very nice consolidation !

Most comments below are about changing existing behavior rather than improving the layout, and may have been handled elsewhere; please filter accordingly.

Comment thread docker/docker-bake.hcl
Comment thread docker/Dockerfile
Comment thread docker/Dockerfile
Comment thread docker/Dockerfile Outdated
Comment thread docker/Dockerfile

@deruyter92 deruyter92 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @C-Achard, see my response below! Mostly accepted all suggestions, thanks for the helpful review!

Comment thread docker/Dockerfile
Comment thread docker/Dockerfile
Comment thread docker/Dockerfile Outdated
Comment thread docker/Dockerfile
deruyter92 and others added 2 commits May 15, 2026 14:02
* update deeplabcut_docker: replace shell script with pure python

* update deeplabcut_docker: modernize setup via pyproject.toml

* update deeplabcut_docker README

* docker: fix default user home directory -> home/{user}

* deeplabcut-docker: update print statement passw->token

* deeplabcut-docker: update pyproject.toml Python range 3.10-3.12

@MMathisLab MMathisLab left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

@MMathisLab MMathisLab merged commit e7762a6 into main May 19, 2026
54 of 55 checks passed
@MMathisLab MMathisLab deleted the jaap/update_docker branch May 19, 2026 08:57
@deruyter92 deruyter92 changed the title [Docker 1] Simplify and modernize Dockerfile [Docker] Simplify and modernize Dockerfile May 20, 2026
This was referenced May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deeplabcut-docker notebook throws permission error Simplify and modernize DeepLabCut Docker images and build pipeline

4 participants