From 2d8e11375d5f71561297b1263a4593d70d1e22ac Mon Sep 17 00:00:00 2001 From: Robert Kalescky Date: Tue, 7 Feb 2023 12:27:50 -0600 Subject: [PATCH] Image naming redo. The image name can be specified directly to docker2singularity thereby negating the need to figure out the orignal name, rename, and move the image. --- biostats_mcgee/build_images.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/biostats_mcgee/build_images.sh b/biostats_mcgee/build_images.sh index fd59ea3d..cda07043 100755 --- a/biostats_mcgee/build_images.sh +++ b/biostats_mcgee/build_images.sh @@ -1,5 +1,8 @@ #!/usr/bin/env zsh +# Set container +name="biostats" + # Set version version="latest" @@ -14,18 +17,17 @@ m[2,3,p]) ;; esac +# Singularity image name +img="${name}_${version}_$(date "+%Y_%m_%d_%H_%M_%S").sif" + # Build container with Docker -docker build --platform ${platform} -t biostats:${version} . +docker build --no-cache --progress=plain\ + --platform ${platform} -t ${name}:${version} . |& tee build.log # Convert Docker image to Singularity image docker run -v /var/run/docker.sock:/var/run/docker.sock\ - -v $PWD:/output --privileged -t --rm\ - singularityware/docker2singularity biostats:${version} | tee build.log - -# Get Singularity image name -simg=$(basename $(awk '/Build complete/{print $NF}' build.log) | tr -d '\b\r') -img="${simg%.*}.sif" -mv $simg $img + -v $PWD:/output --privileged -t --rm singularityware/docker2singularity\ + -n ${img} ${name}:${version} |& tee -a build.log # Change Singularity image permissions if [[ $(uname -s) == "Linux" ]]; then @@ -34,5 +36,5 @@ fi # Update module file with new Singularity image name sed -i'' -e "s/^local img_name.*/local img_name = \'${img}\'/g"\ - biostats.lua + ${name}.lua