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 All 38 Lines | def image_to_podman_args(image): | ||||
| args += [name] | args += [name] | ||||
| return args | return args | ||||
| def run_in_container(image, work_volname, script_volname): | def run_in_container(image, work_volname, script_volname): | ||||
| timeout = 60 * 60 * 2 # 2 hours by default | timeout = 60 * 60 * 2 # 2 hours by default | ||||
| steady_deadline = time.monotonic() + timeout | steady_deadline = time.monotonic() + timeout | ||||
| start_process = verbose_run([ | start_process = verbose_run([ | ||||
| 'podman', 'run', '-d', | 'podman', 'run', '-d', | ||||
| '--image-volume=ignore', | |||||
| 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}', | ||||
| ] + image_to_podman_args(image) + [ | ] + image_to_podman_args(image) + [ | ||||
| script_name, | script_name, | ||||
| ], capture_output=True, encoding='utf-8') | ], capture_output=True, encoding='utf-8') | ||||
| if start_process.returncode != 0: | if start_process.returncode != 0: | ||||
| perror('Cannot run container. Error message:') | perror('Cannot run container. Error message:') | ||||
| print(start_process.stderr) | print(start_process.stderr) | ||||
| ▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines | |||||