Skip to content

Commit d6b89cf

Browse files
authored
Merge pull request #168 from Project-MONAI/build_with_uid
Build package with local UID/GID and fast-retrieve app/package information
2 parents a1d683d + 96ad466 commit d6b89cf

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

monai/deploy/packager/util.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,12 @@ def build_image(args: dict, temp_dir: str):
229229
dockerignore_file.write(docker_ignore_template)
230230

231231
# Build dockerfile into an MAP image
232-
docker_build_cmd = ["docker", "build", "-f", docker_file_path, "-t", tag, temp_dir]
232+
docker_build_cmd = f'''docker build -f "{docker_file_path}" -t {tag} "{temp_dir}"'''
233+
if sys.platform != "win32":
234+
docker_build_cmd += """ --build-arg MONAI_UID=$(id -u) --build-arg MONAI_GID=$(id -g)"""
233235
if no_cache:
234-
docker_build_cmd.append("--no-cache")
235-
proc = subprocess.Popen(docker_build_cmd, stdout=subprocess.PIPE)
236+
docker_build_cmd += " --no-cache"
237+
proc = subprocess.Popen(docker_build_cmd, stdout=subprocess.PIPE, shell=True)
236238

237239
spinner = ProgressSpinner("Building MONAI Application Package... ")
238240
spinner.start()

monai/deploy/runner/runner.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,14 @@ def fetch_map_manifest(map_name: str) -> Tuple[dict, dict, int]:
3939
logger.info("\nReading MONAI App Package manifest...")
4040

4141
with tempfile.TemporaryDirectory() as info_dir:
42-
cmd = f"docker run --rm -a STDOUT -a STDERR -v {info_dir}:/var/run/monai/export/config {map_name}"
43-
42+
if sys.platform == "win32":
43+
cmd = f'docker run --rm -a STDOUT -a STDERR -v "{info_dir}":/var/run/monai/export/config {map_name}'
44+
else:
45+
cmd = f"""docker_id=$(docker create {map_name})
46+
docker cp $docker_id:/etc/monai/app.json "{info_dir}/app.json"
47+
docker cp $docker_id:/etc/monai/pkg.json "{info_dir}/pkg.json"
48+
docker rm -v $docker_id > /dev/null
49+
"""
4450
returncode = run_cmd(cmd)
4551
if returncode != 0:
4652
return {}, {}, returncode

0 commit comments

Comments
 (0)