@@ -12,10 +12,12 @@ run_devcontainer() {
1212 # Generate the devcontainer
1313 eval " $( ./scripts/generate.sh " $@ " | xargs -r -d' \n' -I% echo -n local %\; ) " ;
1414
15- echo " tag=${tag-} " >&2 ;
16- echo " workspace=${workspace-} " >&2 ;
15+ echo " tag=${tag: - } " >&2 ;
16+ echo " workspace=${workspace: - } " >&2 ;
1717
18- if ! test -n " ${workspace-} " || ! test -n " ${tag-} " ; then exit 1; fi ;
18+ if ! test -n " ${workspace:- } " || ! test -n " ${tag:- } " ; then exit 1; fi ;
19+
20+ tag=" ${version:- latest} -${tag} " ;
1921
2022 # Print the generated devcontainer JSON
2123 cat " ${workspace} /.devcontainer/devcontainer.json" >&2 ;
@@ -62,42 +64,51 @@ run_devcontainer() {
6264 vars+=(--remote-env " SCCACHE_REGION=${sccache_region} " );
6365
6466 # Start the devcontainer
65- local -r container_id=" $( \
66- devcontainer up \
67- " ${vars[@]} " \
68- --skip-post-attach \
69- --remove-existing-container \
70- --terminal-rows " ${lines} " \
71- --terminal-columns " ${columns} " \
72- --mount-workspace-git-root false \
73- --workspace-folder " ${workspace} " \
74- --cache-from " docker.io/rapidsai/devcontainers:${tag} " \
75- --mount " type=bind,source=${SSH_AUTH_SOCK} ,target=/tmp/ssh-auth-sock" \
76- --mount " type=bind,source=$( pwd) /.scratch/.aws,target=/home/coder/.aws" \
77- --mount " type=bind,source=$( pwd) /.scratch/.cache,target=/home/coder/.cache" \
78- --mount " type=bind,source=$( pwd) /.scratch/.config,target=/home/coder/.config" \
79- --mount " type=bind,source=$( pwd) /features/src/utils/opt/devcontainer,target=/opt/devcontainer" \
80- --additional-features ' { "./features/src/rapids-build-utils": {} }' \
81- --mount " type=bind,source=$( pwd) /features/src/rapids-build-utils/opt/rapids-build-utils,target=/opt/rapids-build-utils" \
82- | jq -r ' .containerId'
83- ) " ;
84-
85- local -r image_tag=" $(
86- docker image inspect --format ' {{index (split (index .RepoTags 0) ":") 0}}' " $(
87- docker inspect " ${container_id} " --format ' {{index (split .Image ":") 1}}'
88- ) "
89- ) " ;
67+ devcontainer up \
68+ " ${vars[@]} " \
69+ --skip-post-attach \
70+ --remove-existing-container \
71+ --terminal-rows " ${lines} " \
72+ --terminal-columns " ${columns} " \
73+ --mount-workspace-git-root false \
74+ --workspace-folder " ${workspace} " \
75+ --cache-from " docker.io/rapidsai/devcontainers:${tag} " \
76+ --mount " type=bind,source=${SSH_AUTH_SOCK} ,target=/tmp/ssh-auth-sock" \
77+ --mount " type=bind,source=$( pwd) /.scratch/.aws,target=/home/coder/.aws" \
78+ --mount " type=bind,source=$( pwd) /.scratch/.cache,target=/home/coder/.cache" \
79+ --mount " type=bind,source=$( pwd) /.scratch/.config,target=/home/coder/.config" \
80+ --mount " type=bind,source=$( pwd) /features/src/utils/opt/devcontainer,target=/opt/devcontainer" \
81+ --additional-features ' { "./features/src/rapids-build-utils": {} }' \
82+ --mount " type=bind,source=$( pwd) /features/src/rapids-build-utils/opt/rapids-build-utils,target=/opt/rapids-build-utils" \
83+ | tee " ${workspace} /devcontainer-up.log" ;
9084
9185 # shellcheck disable=SC2317
9286 cleanup_2 () {
9387 code=$? ;
9488 set -x;
9589 find ./features/src -maxdepth 1 -type d -name ' *\.[0-9]' -exec rm -r " {}" \;
96- echo " Removing ${container_id} " ;
97- docker rm -f " ${container_id} " > /dev/null 2>&1 || true ;
98- docker rmi -f " ${image_tag} " > /dev/null 2>&1 || true ;
99- docker rmi -f " ${image_tag%% -uid* } " > /dev/null 2>&1 || true ;
90+
91+ local -r container_id=" $( jq -r ' .containerId' " ${1} /devcontainer-up.log" ) " ;
92+
93+ if test -n " ${container_id: +x} " ; then
94+ echo " Removing ${container_id} " ;
95+
96+ local -r image_tag=" $(
97+ docker image inspect --format ' {{index (split (index .RepoTags 0) ":") 0}}' " $(
98+ docker inspect " ${container_id} " --format ' {{index (split .Image ":") 1}}'
99+ ) "
100+ ) " ;
101+
102+ docker rm -f " ${container_id} " > /dev/null 2>&1 || true ;
103+
104+ if test -n " ${image_tag: +x} " ; then
105+ docker rmi -f " ${image_tag} " > /dev/null 2>&1 || true ;
106+ docker rmi -f " ${image_tag%% -uid* } " > /dev/null 2>&1 || true ;
107+ fi
108+ fi
109+
100110 rm -rf " ${1} " ;
111+
101112 exit " ${code} " ;
102113 }
103114
0 commit comments