From d0d87c8c7c91c63f8eafe6f21b4108e15f6c2ef0 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 28 Jan 2025 19:00:09 -0800 Subject: [PATCH 01/22] Shell out to `docker buildx build` to build images pydocker uses the HTTP API (equivalent to `docker build`) which has been dead for ages. `docker buildx` (the interface to BuildKit) is what we *should* be using, but alas pydocker does not currently support it and I suspect it never will (https://github.com/docker/docker-py/issues/2230). This PR simply shells out, as I think that's the way. Fixes https://github.com/jupyterhub/repo2docker/issues/875 --- repo2docker/docker.py | 52 +++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index 830e5c78..8ebc571c 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -2,12 +2,19 @@ Docker container engine for repo2docker """ +import subprocess +import tarfile +import tempfile +from queue import Empty, Queue +from threading import Thread + from iso8601 import parse_date from traitlets import Dict import docker from .engine import Container, ContainerEngine, ContainerEngineException, Image +from .utils import execute_cmd class DockerContainer(Container): @@ -53,7 +60,7 @@ class DockerEngine(ContainerEngine): https://docker-py.readthedocs.io/en/4.2.0/api.html#module-docker.api.build """ - string_output = False + string_output = True extra_init_args = Dict( {}, @@ -82,8 +89,8 @@ def __init__(self, *, parent): def build( self, *, - buildargs=None, - cache_from=None, + buildargs: dict | None = None, + cache_from: list[str] | None = None, container_limits=None, tag="", custom_context=False, @@ -94,22 +101,29 @@ def build( platform=None, **kwargs, ): - return self._apiclient.build( - buildargs=buildargs, - cache_from=cache_from, - container_limits=container_limits, - forcerm=True, - rm=True, - tag=tag, - custom_context=custom_context, - decode=True, - dockerfile=dockerfile, - fileobj=fileobj, - path=path, - labels=labels, - platform=platform, - **kwargs, - ) + args = ["docker", "buildx", "build", "--progress", "plain"] + if buildargs: + for k, v in buildargs.items(): + args += ["--build-arg", f"{k}={v}"] + + if cache_from: + for cf in cache_from: + args += ["--cache-from", cf] + + if dockerfile: + args += ["--file", dockerfile] + + if tag: + args += ["--tag", tag] + + if fileobj: + with tempfile.TemporaryDirectory() as d: + tarf = tarfile.open(fileobj=fileobj) + tarf.extractall(d) + + args += [d] + + yield from execute_cmd(args, True) def images(self): images = self._apiclient.images() From 1ca89b828821bd1d5b9a5e715670784c47808dd6 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 28 Jan 2025 19:10:26 -0800 Subject: [PATCH 02/22] Remove type hints for now --- repo2docker/docker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index 8ebc571c..29f2acfe 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -89,8 +89,8 @@ def __init__(self, *, parent): def build( self, *, - buildargs: dict | None = None, - cache_from: list[str] | None = None, + buildargs=None, + cache_from=None, container_limits=None, tag="", custom_context=False, From 258daa7c2089943b3460d479fba5397ee549b130 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 28 Jan 2025 19:12:09 -0800 Subject: [PATCH 03/22] Automatically load built image to mimic previous behavior --- repo2docker/docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index 29f2acfe..81219982 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -101,7 +101,7 @@ def build( platform=None, **kwargs, ): - args = ["docker", "buildx", "build", "--progress", "plain"] + args = ["docker", "buildx", "build", "--progress", "plain", "--load"] if buildargs: for k, v in buildargs.items(): args += ["--build-arg", f"{k}={v}"] From 93cb0d757c544f0c2e6d392f9d0395ad88cf0c10 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 28 Jan 2025 19:14:08 -0800 Subject: [PATCH 04/22] Support `Dockerfile` too --- repo2docker/docker.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index 81219982..dc36a0a6 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -124,6 +124,11 @@ def build( args += [d] yield from execute_cmd(args, True) + else: + # Assume 'path' is passed in + args += [path] + + yield from execute_cmd(args, True) def images(self): images = self._apiclient.images() From 77ed4996809213076f8a03c6c477723f01895314 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 28 Jan 2025 19:17:45 -0800 Subject: [PATCH 05/22] Support --platform and --labels --- repo2docker/docker.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index dc36a0a6..8116ae8b 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -116,6 +116,13 @@ def build( if tag: args += ["--tag", tag] + if labels: + for k, v in labels: + args += ["--label", f"{k}={v}"] + + if platform: + args += ["--platform", platform] + if fileobj: with tempfile.TemporaryDirectory() as d: tarf = tarfile.open(fileobj=fileobj) From 743c9f964cc8ae4c3f01faa41f392d75bc14cfb0 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 28 Jan 2025 19:21:53 -0800 Subject: [PATCH 06/22] Iterate labels as dicts --- repo2docker/docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index 8116ae8b..64f056ba 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -117,7 +117,7 @@ def build( args += ["--tag", tag] if labels: - for k, v in labels: + for k, v in labels.items(): args += ["--label", f"{k}={v}"] if platform: From b1cedc4a78a1307e99fd0a92ab5dda1b49687b3a Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 28 Jan 2025 20:29:42 -0800 Subject: [PATCH 07/22] Remove some patched out tests that don't apply anymore --- tests/unit/test_app.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/tests/unit/test_app.py b/tests/unit/test_app.py index d37103e6..67cddc07 100644 --- a/tests/unit/test_app.py +++ b/tests/unit/test_app.py @@ -78,21 +78,6 @@ def test_local_dir_image_name(repo_with_content): ) -def test_build_kwargs(repo_with_content): - upstream, sha1 = repo_with_content - argv = [upstream] - app = make_r2d(argv) - app.extra_build_kwargs = {"somekey": "somevalue"} - - with patch.object(docker.APIClient, "build") as builds: - builds.return_value = [] - app.build() - builds.assert_called_once() - args, kwargs = builds.call_args - assert "somekey" in kwargs - assert kwargs["somekey"] == "somevalue" - - def test_run_kwargs(repo_with_content): upstream, sha1 = repo_with_content argv = [upstream] @@ -107,25 +92,6 @@ def test_run_kwargs(repo_with_content): assert kwargs["somekey"] == "somevalue" -def test_root_not_allowed(): - with TemporaryDirectory() as src, patch("os.geteuid") as geteuid: - geteuid.return_value = 0 - argv = [src] - with pytest.raises(SystemExit) as exc: - app = make_r2d(argv) - assert exc.code == 1 - - with pytest.raises(ValueError): - app = Repo2Docker(repo=src, run=False) - app.build() - - app = Repo2Docker(repo=src, user_id=1000, user_name="jovyan", run=False) - app.initialize() - with patch.object(docker.APIClient, "build") as builds: - builds.return_value = [] - app.build() - builds.assert_called_once() - def test_dryrun_works_without_docker(tmpdir, capsys): with chdir(tmpdir): From 8e20b60c69a598d9bd881d20a22a41440ac5eba6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 04:30:03 +0000 Subject: [PATCH 08/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/unit/test_app.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/test_app.py b/tests/unit/test_app.py index 67cddc07..7828c318 100644 --- a/tests/unit/test_app.py +++ b/tests/unit/test_app.py @@ -92,7 +92,6 @@ def test_run_kwargs(repo_with_content): assert kwargs["somekey"] == "somevalue" - def test_dryrun_works_without_docker(tmpdir, capsys): with chdir(tmpdir): with patch.object(docker, "APIClient") as client: From a03bf74d1f5e2ae66a8d054b798846724055869a Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 28 Jan 2025 20:31:26 -0800 Subject: [PATCH 09/22] Add a warning + check to make sure docker is installed --- repo2docker/docker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index 64f056ba..6bd545a8 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -2,11 +2,9 @@ Docker container engine for repo2docker """ -import subprocess +import shutil import tarfile import tempfile -from queue import Empty, Queue -from threading import Thread from iso8601 import parse_date from traitlets import Dict @@ -101,6 +99,8 @@ def build( platform=None, **kwargs, ): + if not shutil.which("docker"): + raise RuntimeError("The docker commandline client must be installed") args = ["docker", "buildx", "build", "--progress", "plain", "--load"] if buildargs: for k, v in buildargs.items(): From d9407061284bda4cdb32e67d47edbf37ae1b1762 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Wed, 29 Jan 2025 08:25:23 -0800 Subject: [PATCH 10/22] Add extra_buildx_build_args --- repo2docker/docker.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index 6bd545a8..6d622bec 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -7,7 +7,7 @@ import tempfile from iso8601 import parse_date -from traitlets import Dict +from traitlets import Dict, List, Unicode import docker @@ -74,6 +74,15 @@ class DockerEngine(ContainerEngine): config=True, ) + extra_buildx_build_args = List( + Unicode, + [], + help=""" + Extra commandline arguments to pass to `docker buildx build` when building the image. + """, + help=True + ) + def __init__(self, *, parent): super().__init__(parent=parent) try: @@ -123,6 +132,9 @@ def build( if platform: args += ["--platform", platform] + # place extra args right *before* the path + args += self.extra_buildx_build_args + if fileobj: with tempfile.TemporaryDirectory() as d: tarf = tarfile.open(fileobj=fileobj) From 5b9615643bc612355f5afd9dd0b9cda90e0e7f41 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Wed, 29 Jan 2025 08:28:24 -0800 Subject: [PATCH 11/22] Fix trait definition --- repo2docker/docker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index 6d622bec..4f51e5fc 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -75,12 +75,12 @@ class DockerEngine(ContainerEngine): ) extra_buildx_build_args = List( - Unicode, + [Unicode], [], help=""" Extra commandline arguments to pass to `docker buildx build` when building the image. """, - help=True + config=True ) def __init__(self, *, parent): From d7968bbf8eed7007002935493bce7a0aaa63fa0b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 18:34:40 +0000 Subject: [PATCH 12/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- repo2docker/docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index 4f51e5fc..8fb35011 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -80,7 +80,7 @@ class DockerEngine(ContainerEngine): help=""" Extra commandline arguments to pass to `docker buildx build` when building the image. """, - config=True + config=True, ) def __init__(self, *, parent): From 6df3ec637757465c1f4d72097c4afb5588a32ed4 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Wed, 29 Jan 2025 21:34:54 -0800 Subject: [PATCH 13/22] Fix traitlet again? --- repo2docker/docker.py | 1 - 1 file changed, 1 deletion(-) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index 8fb35011..e2eeac06 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -75,7 +75,6 @@ class DockerEngine(ContainerEngine): ) extra_buildx_build_args = List( - [Unicode], [], help=""" Extra commandline arguments to pass to `docker buildx build` when building the image. From 087c332638c578676422268df93c2b22aa45e8ae Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Sat, 8 Feb 2025 13:34:56 -0800 Subject: [PATCH 14/22] Specify what kinda list extra_buildx_build_args can be --- repo2docker/docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo2docker/docker.py b/repo2docker/docker.py index e2eeac06..7fcbc31e 100644 --- a/repo2docker/docker.py +++ b/repo2docker/docker.py @@ -75,7 +75,7 @@ class DockerEngine(ContainerEngine): ) extra_buildx_build_args = List( - [], + Unicode(), help=""" Extra commandline arguments to pass to `docker buildx build` when building the image. """, From 07ef92ecbdcf64234402c79961323a043078cc45 Mon Sep 17 00:00:00 2001 From: Yuvi Panda Date: Tue, 11 Feb 2025 12:17:14 -0800 Subject: [PATCH 15/22] Add extra_args test Co-authored-by: Min RK --- tests/unit/test_app.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/unit/test_app.py b/tests/unit/test_app.py index 7828c318..49903d37 100644 --- a/tests/unit/test_app.py +++ b/tests/unit/test_app.py @@ -78,6 +78,20 @@ def test_local_dir_image_name(repo_with_content): ) +def test_extra_buildx_build_args(repo_with_content): + upstream, sha1 = repo_with_content + argv = ['--DockerEngine.extra_buildx_build_args=--check', upstream] + app = make_r2d(argv) + with patch("repo2docker.docker.execute_cmd") as execute_cmd: + app.build() + + args, kwargs = execute_cmd.call_args + cmd = args[0] + assert cmd[:3] == ["docker", "buildx", "build"] + # make sure it's inserted before the end + assert "--check" in cmd[:-1] + + def test_run_kwargs(repo_with_content): upstream, sha1 = repo_with_content argv = [upstream] From bd615901cb0077275b09e9c6b0a3dc1f8d1d2add Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Feb 2025 20:17:24 +0000 Subject: [PATCH 16/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/unit/test_app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_app.py b/tests/unit/test_app.py index 49903d37..0ee4d0b3 100644 --- a/tests/unit/test_app.py +++ b/tests/unit/test_app.py @@ -80,11 +80,11 @@ def test_local_dir_image_name(repo_with_content): def test_extra_buildx_build_args(repo_with_content): upstream, sha1 = repo_with_content - argv = ['--DockerEngine.extra_buildx_build_args=--check', upstream] + argv = ["--DockerEngine.extra_buildx_build_args=--check", upstream] app = make_r2d(argv) with patch("repo2docker.docker.execute_cmd") as execute_cmd: app.build() - + args, kwargs = execute_cmd.call_args cmd = args[0] assert cmd[:3] == ["docker", "buildx", "build"] From 34399f8f87cf5af2d39ce7341e17ca7c31d714fa Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 11 Feb 2025 20:50:39 -0800 Subject: [PATCH 17/22] Throw error if using --build-memory-limit --- repo2docker/__main__.py | 13 ++++++------- repo2docker/app.py | 12 ++++++++++-- tests/unit/test_args.py | 7 ++----- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/repo2docker/__main__.py b/repo2docker/__main__.py index fb4e7846..00ad0991 100644 --- a/repo2docker/__main__.py +++ b/repo2docker/__main__.py @@ -140,7 +140,8 @@ def get_argparser(): argparser.add_argument( "--build-memory-limit", - help="Total Memory that can be used by the docker build process", + # Removed argument, but we still want to support printing an error message if this is passed + help=argparse.SUPPRESS ) argparser.add_argument( @@ -434,12 +435,10 @@ def make_r2d(argv=None): sys.exit(1) if args.build_memory_limit: - # if the string only contains numerals we assume it should be an int - # and specifies a size in bytes - if args.build_memory_limit.isnumeric(): - r2d.build_memory_limit = int(args.build_memory_limit) - else: - r2d.build_memory_limit = args.build_memory_limit + # We no longer support build_memory_limit, it must be set in the builder instance + print("--build-memory-limit is no longer supported", file=sys.stderr) + print("Use `docker buildx create` to create a custom builder with appropriate memory limits instead", file=sys.stderr) + sys.exit(-1) if args.environment and not r2d.run: print("To specify environment variables, you also need to run " "the container") diff --git a/repo2docker/app.py b/repo2docker/app.py index a2a9a92d..56eddbbb 100755 --- a/repo2docker/app.py +++ b/repo2docker/app.py @@ -165,13 +165,20 @@ def _default_log_level(self): build_memory_limit = ByteSpecification( 0, help=""" - Total memory that can be used by the docker image building process. + Unsupported. - Set to 0 for no limits. + When using docker, please use `docker buildx create` to create a new buildkit + builder with appropriate limits instead. """, config=True, ) + @observe("build_memory_limit") + def build_memory_limit_changed(self, change): + print("Setting build_memory_limit is not supported", file=sys.stderr) + print("Use `docker buildx create` to create a custom builder with appropriate memory limits instead", file=sys.stderr) + sys.exit(-1) + volumes = Dict( {}, help=""" @@ -856,6 +863,7 @@ def build(self): for l in picked_buildpack.build( docker_client, self.output_image_spec, + # This is deprecated, but passing it anyway to not break backwards compatibility self.build_memory_limit, build_args, self.cache_from, diff --git a/tests/unit/test_args.py b/tests/unit/test_args.py index d3e304f0..e3257f44 100644 --- a/tests/unit/test_args.py +++ b/tests/unit/test_args.py @@ -50,11 +50,8 @@ def test_mem_limit(): """ Test various ways of passing --build-memory-limit """ - r2d = make_r2d(["--build-memory-limit", "1024", "."]) - assert int(r2d.build_memory_limit) == 1024 - - r2d = make_r2d(["--build-memory-limit", "3K", "."]) - assert int(r2d.build_memory_limit) == 1024 * 3 + with pytest.raises(SystemExit): + r2d = make_r2d(["--build-memory-limit", "1024", "."]) def test_run_required(): From bd39320153c8a1eae6c13c17464dd12307be2ea5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Feb 2025 04:52:38 +0000 Subject: [PATCH 18/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- repo2docker/__main__.py | 7 +++++-- repo2docker/app.py | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/repo2docker/__main__.py b/repo2docker/__main__.py index 00ad0991..748e0d02 100644 --- a/repo2docker/__main__.py +++ b/repo2docker/__main__.py @@ -141,7 +141,7 @@ def get_argparser(): argparser.add_argument( "--build-memory-limit", # Removed argument, but we still want to support printing an error message if this is passed - help=argparse.SUPPRESS + help=argparse.SUPPRESS, ) argparser.add_argument( @@ -437,7 +437,10 @@ def make_r2d(argv=None): if args.build_memory_limit: # We no longer support build_memory_limit, it must be set in the builder instance print("--build-memory-limit is no longer supported", file=sys.stderr) - print("Use `docker buildx create` to create a custom builder with appropriate memory limits instead", file=sys.stderr) + print( + "Use `docker buildx create` to create a custom builder with appropriate memory limits instead", + file=sys.stderr, + ) sys.exit(-1) if args.environment and not r2d.run: diff --git a/repo2docker/app.py b/repo2docker/app.py index 56eddbbb..c7bb8039 100755 --- a/repo2docker/app.py +++ b/repo2docker/app.py @@ -176,7 +176,10 @@ def _default_log_level(self): @observe("build_memory_limit") def build_memory_limit_changed(self, change): print("Setting build_memory_limit is not supported", file=sys.stderr) - print("Use `docker buildx create` to create a custom builder with appropriate memory limits instead", file=sys.stderr) + print( + "Use `docker buildx create` to create a custom builder with appropriate memory limits instead", + file=sys.stderr, + ) sys.exit(-1) volumes = Dict( From b243cb60792112c8fd009ee17e0417e8b5ef5643 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 11 Feb 2025 20:58:36 -0800 Subject: [PATCH 19/22] Add another unit test for sys.exit behavior --- tests/unit/test_args.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/test_args.py b/tests/unit/test_args.py index e3257f44..d416d204 100644 --- a/tests/unit/test_args.py +++ b/tests/unit/test_args.py @@ -53,6 +53,8 @@ def test_mem_limit(): with pytest.raises(SystemExit): r2d = make_r2d(["--build-memory-limit", "1024", "."]) + with pytest.raises(SystemExit): + r2d = make_r2d(["--Repo2Docker.build_memory_limit", "1024", "."]) def test_run_required(): """ From 6484673698b30c250215919b4cb8a7c95d45cd61 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Feb 2025 04:59:12 +0000 Subject: [PATCH 20/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/unit/test_args.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/test_args.py b/tests/unit/test_args.py index d416d204..a116a988 100644 --- a/tests/unit/test_args.py +++ b/tests/unit/test_args.py @@ -56,6 +56,7 @@ def test_mem_limit(): with pytest.raises(SystemExit): r2d = make_r2d(["--Repo2Docker.build_memory_limit", "1024", "."]) + def test_run_required(): """ Test all the things that should fail if we pass in --no-run From a9a38de516ea9e613289418ff89dfb37ec4c8e01 Mon Sep 17 00:00:00 2001 From: Yuvi Panda Date: Wed, 12 Feb 2025 08:17:50 -0800 Subject: [PATCH 21/22] Clarify where memory limits are Co-authored-by: Simon Li --- repo2docker/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo2docker/app.py b/repo2docker/app.py index c7bb8039..0d817452 100755 --- a/repo2docker/app.py +++ b/repo2docker/app.py @@ -177,7 +177,7 @@ def _default_log_level(self): def build_memory_limit_changed(self, change): print("Setting build_memory_limit is not supported", file=sys.stderr) print( - "Use `docker buildx create` to create a custom builder with appropriate memory limits instead", + "Check your build engine documentation to set memory limits. Use `docker buildx create` if using the default builder to create a custom builder with appropriate memory limits", file=sys.stderr, ) sys.exit(-1) From 709eb8e527c377aee071766d433bd6691235e403 Mon Sep 17 00:00:00 2001 From: Yuvi Panda Date: Wed, 12 Feb 2025 21:23:41 -0800 Subject: [PATCH 22/22] Update error message Co-authored-by: Simon Li --- repo2docker/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo2docker/__main__.py b/repo2docker/__main__.py index 748e0d02..62d67f02 100644 --- a/repo2docker/__main__.py +++ b/repo2docker/__main__.py @@ -438,7 +438,7 @@ def make_r2d(argv=None): # We no longer support build_memory_limit, it must be set in the builder instance print("--build-memory-limit is no longer supported", file=sys.stderr) print( - "Use `docker buildx create` to create a custom builder with appropriate memory limits instead", + "Check your build engine documentation to set memory limits. Use `docker buildx create` if using the default builder to create a custom builder with appropriate memory limits", file=sys.stderr, ) sys.exit(-1)