@@ -129,6 +129,10 @@ CTR_CARGO_SECCOMPILER_TARGET_DIR="$CTR_FC_BUILD_DIR/seccompiler"
129
129
# Full path to the microVM images cache dir
130
130
CTR_MICROVM_IMAGES_DIR=" $CTR_FC_BUILD_DIR /img"
131
131
132
+ # Full path to the poetry tmp directory on the container, used for holding
133
+ # the lock and toml files.
134
+ CTR_POETRY_TMP_DIR=" /tmp/poetry"
135
+
132
136
# Full path to the public key mapping on the guest
133
137
PUB_KEY_PATH=/root/.ssh/id_rsa.pub
134
138
@@ -337,16 +341,14 @@ cmd_fix_perms() {
337
341
cmd_build_devctr () {
338
342
arch=$( uname -m)
339
343
docker_file_name=" Dockerfile.$arch "
340
- should_update_python_packages=true
341
- build_args=" "
344
+ build_args=" --build-arg TMP_POETRY_DIR=$CTR_POETRY_TMP_DIR "
342
345
343
346
while [ $# -gt 0 ]; do
344
347
case " $1 " in
345
348
" -h" |" --help" ) { cmd_help; exit 1; } ;;
346
- " -n" |" --no-python-package-update " )
349
+ " -n" |" --no-python-package-upgrade " )
347
350
shift
348
- should_update_python_packages=false
349
- build_args=" --build-arg POETRY_LOCK_PATH=tools/devctr/poetry.lock"
351
+ build_args=" $build_args --build-arg POETRY_LOCK_PATH=tools/devctr/poetry.lock"
350
352
;;
351
353
" --" ) { shift ; break ; } ;;
352
354
* )
@@ -358,9 +360,9 @@ cmd_build_devctr() {
358
360
359
361
docker build -t " $DEVCTR_IMAGE_NO_TAG " -f " $FC_DEVCTR_DIR /$docker_file_name " $build_args .
360
362
361
- if [ " $should_update_python_packages " = true ] ; then
362
- update_python_package_version
363
- fi
363
+ # Copy back the lockfile, since a new dependency or version would have
364
+ # updated it.
365
+ copy_poetry_lockfile
364
366
}
365
367
366
368
# Prompt the user for confirmation before proceeding.
@@ -611,32 +613,20 @@ test_key() {
611
613
[ $ret -ne 0 ] && die " $1 is not a valid key file."
612
614
}
613
615
614
- # Tries to update any outdated python packages on the container,
615
- # locks the new versions and copies back the ```poetry.lock```
616
- # file to the host.
616
+ # Copies the ```poetry.lock``` file to the host, upgrading the versions if
617
+ # requested.
617
618
#
618
- update_python_package_version () {
619
- say " Updating python packages..."
620
-
619
+ copy_poetry_lockfile () {
621
620
# defined in Dockerfile
622
- poetry_dir_on_container=" /tmp/poetry"
623
621
lock_file_location_on_host=" $FC_DEVCTR_DIR /poetry.lock"
624
622
image_id=$( docker images -q " $DEVCTR_IMAGE_NO_TAG " | head -n 1)
625
623
dummy_container_name=$( uuidgen)
626
- dummy_container_id=$( docker create -ti --name \
627
- " $dummy_container_name " \
628
- " $image_id " \
629
- bash)
630
-
631
- docker start " $dummy_container_id "
632
- cmd=" cd " $poetry_dir_on_container " ; poetry update"
633
- docker exec -ti " $dummy_container_id " /bin/bash -c " ${cmd} "
624
+ dummy_container_id=$( docker create --name " $dummy_container_name " " $image_id " bash)
625
+
634
626
docker cp \
635
- " $dummy_container_id " :/tmp/poetry /poetry.lock \
627
+ " $dummy_container_id " :" $CTR_POETRY_TMP_DIR " /poetry.lock \
636
628
" $lock_file_location_on_host "
637
- docker commit " $dummy_container_id " " $DEVCTR_IMAGE_NO_TAG "
638
629
639
- docker stop " $dummy_container_id "
640
630
docker rm -f " $dummy_container_name "
641
631
}
642
632
0 commit comments