From 632644744f287eb4e574fbc6d2c82083d89e5f59 Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Wed, 25 Oct 2023 00:23:58 -0700 Subject: [PATCH 1/7] get the full image id not just the truncated version --- src/rocker/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rocker/core.py b/src/rocker/core.py index 03af51c..af5f742 100644 --- a/src/rocker/core.py +++ b/src/rocker/core.py @@ -246,7 +246,7 @@ def docker_build(docker_client = None, output_callback = None, **kwargs): image_id = match.group(1) if image_id: - return image_id + return docker_client.inspect_image(image_id).get('Id') else: print("no more output and success not detected") return None From 13801e333171d1ff8221a1e877e545245343b28b Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Wed, 25 Oct 2023 00:31:58 -0700 Subject: [PATCH 2/7] enable podman runtime --- src/rocker/core.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/rocker/core.py b/src/rocker/core.py index af5f742..3ffa27d 100644 --- a/src/rocker/core.py +++ b/src/rocker/core.py @@ -365,7 +365,14 @@ def generate_docker_cmd(self, command='', **kwargs): image = image_name else: image = self.image_id - cmd = "docker run" + cmd = "" + podman_prefix = "" + if kwargs.get('use_podman'): + cmd += "podman run" + podman_prefix = "docker-daemon:" + else: + cmd += "docker run" + if(not kwargs.get('nocleanup')): # remove container only if --nocleanup is not present cmd += " --rm" @@ -374,7 +381,7 @@ def generate_docker_cmd(self, command='', **kwargs): if operating_mode != OPERATIONS_NON_INTERACTIVE: # only disable for OPERATIONS_NON_INTERACTIVE cmd += " -it" - cmd += "%(docker_args)s %(image)s %(command)s" % locals() + cmd += "%(docker_args)s %(podman_prefix)s%(image)s %(command)s" % locals() return cmd def run(self, command='', **kwargs): From c3f57f54de69de47f31908923d31dfa77ee277da Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Wed, 25 Oct 2023 00:32:19 -0700 Subject: [PATCH 3/7] add cli option to use podman --- src/rocker/cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rocker/cli.py b/src/rocker/cli.py index 9e6743b..c26542c 100644 --- a/src/rocker/cli.py +++ b/src/rocker/cli.py @@ -37,6 +37,7 @@ def main(): parser.add_argument('--nocleanup', action='store_true', help='do not remove the docker container when stopped') parser.add_argument('--persist-image', action='store_true', help='do not remove the docker image when stopped', default=False) #TODO(tfoote) Add a name to it if persisting parser.add_argument('--pull', action='store_true') + parser.add_argument('--use-podman', action='store_true') parser.add_argument('--version', action='version', version='%(prog)s ' + get_rocker_version()) From 8b354ec83c4ad6c1ba338af30408ef85204c1272 Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Wed, 25 Oct 2023 01:04:38 -0700 Subject: [PATCH 4/7] make podman a separate command rodman --- setup.py | 3 ++- src/rocker/cli.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 2cc1d9d..a81e893 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,8 @@ 'package_data': {'rocker': ['templates/*.em']}, 'entry_points': { 'console_scripts': [ - 'rocker = rocker.cli:main', + 'rocker = rocker.cli:rocker_main', + 'rodman = rocker.cli:rodman_main', 'detect_docker_image_os = rocker.cli:detect_image_os', ], 'rocker.extensions': [ diff --git a/src/rocker/cli.py b/src/rocker/cli.py index c26542c..495c837 100644 --- a/src/rocker/cli.py +++ b/src/rocker/cli.py @@ -25,7 +25,7 @@ from .os_detector import detect_os -def main(): +def main(implementation='rocker'): parser = argparse.ArgumentParser( description='A tool for running docker with extra options', @@ -37,7 +37,6 @@ def main(): parser.add_argument('--nocleanup', action='store_true', help='do not remove the docker container when stopped') parser.add_argument('--persist-image', action='store_true', help='do not remove the docker image when stopped', default=False) #TODO(tfoote) Add a name to it if persisting parser.add_argument('--pull', action='store_true') - parser.add_argument('--use-podman', action='store_true') parser.add_argument('--version', action='version', version='%(prog)s ' + get_rocker_version()) @@ -51,6 +50,7 @@ def main(): args = parser.parse_args() args_dict = vars(args) + args_dict['use_podman'] = implementation == 'podman' if args.noexecute: from .core import OPERATIONS_DRY_RUN @@ -95,3 +95,10 @@ def detect_image_os(): return 0 else: return 1 + +def rocker_main(): + return main(implementation='rocker') + + +def rodman_main(): + return main(implementation='podman') From e40602f415f332e17857aa66fdcc2963ac83fe4d Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Thu, 14 Nov 2024 15:03:03 -0800 Subject: [PATCH 5/7] Add CI for rodman entrypoint --- .github/workflows/basic-ci.yaml | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/basic-ci.yaml b/.github/workflows/basic-ci.yaml index 57cd204..3301e98 100644 --- a/.github/workflows/basic-ci.yaml +++ b/.github/workflows/basic-ci.yaml @@ -27,6 +27,25 @@ jobs: cli_smoke_tests: name: CLI smoke tests runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: [3.8, '3.x'] + executable_name: [rocker, rodman] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Check main runs + run: | + ${{ matrix.executable_name }} ubuntu 'true' + - name: Check rocker help + run: | + ${{ matrix.executable_name }} -h + test_helper_functions: + name: Test Helper Functions + runs-on: ubuntu-22.04 strategy: matrix: python-version: [3.8, '3.x'] @@ -46,10 +65,3 @@ jobs: - name: Check detector help run: | detect_docker_image_os ubuntu -h - - name: Check main runs - run: | - rocker ubuntu 'true' - - name: Check rocker help - run: | - rocker -h - From 830d70b32073fffd1ba2846dcc02b23bb8778e9a Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Thu, 14 Nov 2024 15:05:17 -0800 Subject: [PATCH 6/7] run the install --- .github/workflows/basic-ci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/basic-ci.yaml b/.github/workflows/basic-ci.yaml index 3301e98..8cec53e 100644 --- a/.github/workflows/basic-ci.yaml +++ b/.github/workflows/basic-ci.yaml @@ -37,6 +37,10 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install Dependencies And Self + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install -e . - name: Check main runs run: | ${{ matrix.executable_name }} ubuntu 'true' From 80a01769cb1c4351c8007d9f8c60fa36fcf83485 Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Fri, 15 Nov 2024 11:31:03 -0800 Subject: [PATCH 7/7] Enable UID GID persistence in podman --- src/rocker/extensions.py | 5 +++++ test/test_extension.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/rocker/extensions.py b/src/rocker/extensions.py index 3e22b71..799b4e3 100644 --- a/src/rocker/extensions.py +++ b/src/rocker/extensions.py @@ -300,6 +300,11 @@ class User(RockerExtension): def get_name(): return 'user' + def get_docker_args(self, cliargs): + if cliargs.get('use_podman', False): + return ' --userns=keep-id ' + return '' + def get_environment_subs(self): if not self._env_subs: user_vars = ['name', 'uid', 'gid', 'gecos','dir', 'shell'] diff --git a/test/test_extension.py b/test/test_extension.py index d264c35..7779fee 100644 --- a/test/test_extension.py +++ b/test/test_extension.py @@ -419,6 +419,14 @@ def test_user_extension(self): snippet_result = p.get_snippet(user_override_active_cliargs) self.assertFalse('-s' in snippet_result) + user_podman_args = mock_cliargs + args_result = p.get_docker_args(user_podman_args) + self.assertNotIn('--userns=keep-id', args_result) + + user_podman_args['use_podman'] = True + args_result = p.get_docker_args(user_podman_args) + self.assertIn('--userns=keep-id', args_result) + @pytest.mark.docker def test_user_collisions(self): plugins = list_plugins()