Changeset View
Changeset View
Standalone View
Standalone View
lilybuild/podman-helper
| Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | def start_helper_service(work_volname, script_volname): | ||||
| res = verbose_run([ | res = verbose_run([ | ||||
| 'podman', 'run', '--rm', '-d', '--name', container_name, | 'podman', 'run', '--rm', '-d', '--name', container_name, | ||||
| f'--mount=type=volume,source={work_volname},destination={work_vol_mount_dir}', | f'--mount=type=volume,source={work_volname},destination={work_vol_mount_dir}', | ||||
| f'--mount=type=volume,source={script_volname},destination={script_vol_mount_dir}', | f'--mount=type=volume,source={script_volname},destination={script_vol_mount_dir}', | ||||
| f'--pod={pod}', | f'--pod={pod}', | ||||
| f'--net={networks[0]}', | f'--net={networks[0]}', | ||||
| f'--network-alias={alias}', | f'--network-alias={alias}', | ||||
| '--image-volume=ignore', | |||||
| '--label', 'lilybuild=helper', | '--label', 'lilybuild=helper', | ||||
| '-e', 'PUID=0', | '-e', 'PUID=0', | ||||
| '-e', 'PGID=0', | '-e', 'PGID=0', | ||||
| '-e', f'PUBLIC_KEY={pub_key}', | '-e', f'PUBLIC_KEY={pub_key}', | ||||
| '-e', 'USER_NAME=helper', | '-e', 'USER_NAME=helper', | ||||
| '-e', 'SUDO_ACCESS=true', | '-e', 'SUDO_ACCESS=true', | ||||
| volume_helper_image, | volume_helper_image, | ||||
| ], check=True, capture_output=True, encoding='utf-8') | ], check=True, capture_output=True, encoding='utf-8') | ||||
| ▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | except subprocess.TimeoutExpired: | ||||
| retcode = 1 | retcode = 1 | ||||
| except subprocess.CalledProcessError as e: | except subprocess.CalledProcessError as e: | ||||
| perror('Cannot inspect container', e) | perror('Cannot inspect container', e) | ||||
| finally: | finally: | ||||
| pinfo('Cleaning up container...') | pinfo('Cleaning up container...') | ||||
| stop_proc = verbose_run(['podman', 'container', 'stop', '--', container_id]) | stop_proc = verbose_run(['podman', 'container', 'stop', '--', container_id]) | ||||
| if stop_proc.returncode != 0: | if stop_proc.returncode != 0: | ||||
| perror('Cannot stop container.') | perror('Cannot stop container.') | ||||
| rm_proc = verbose_run(['podman', 'container', 'rm', '-f', '--', container_id]) | # -v removes anonymous volumes associated with the container | ||||
| rm_proc = verbose_run(['podman', 'container', 'rm', '-f', '-v', '--', container_id]) | |||||
| pinfo('Cleaned.') | pinfo('Cleaned.') | ||||
| return retcode | return retcode | ||||
| def main(): | def main(): | ||||
| image = json.loads(sys.argv[1]) | image = json.loads(sys.argv[1]) | ||||
| work_dir = sys.argv[2] | work_dir = sys.argv[2] | ||||
| script_dir = sys.argv[3] | script_dir = sys.argv[3] | ||||
| result_dir = sys.argv[4] | result_dir = sys.argv[4] | ||||
| ▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines | |||||