From 4b989450a4b885630d2d6fc00be24333540097c5 Mon Sep 17 00:00:00 2001 From: AdamSimpson Date: Sun, 4 Feb 2018 13:37:44 -0500 Subject: [PATCH] Update dockerfile to get around Singularity git issue 855. Also produce less secondary output --- Builder/scripts/docker-builder-backend.sh | 26 +++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Builder/scripts/docker-builder-backend.sh b/Builder/scripts/docker-builder-backend.sh index 8d24f5d..3a95c9f 100755 --- a/Builder/scripts/docker-builder-backend.sh +++ b/Builder/scripts/docker-builder-backend.sh @@ -19,12 +19,20 @@ case ${i} in esac done +# We don't wish to show the output of secondary commands unless debugging is enabled +if [[ -z ${DEBUG_FLAG+x} ]]; then + exec {OUT_FD} &> /dev/null +else + OUT_FD=1 +fi + + # Provide read only access to the private gitlab docker repository if using the container-recipes docker registry grep 'FROM code.ornl.gov:4567' ./container.def GREP_RC=$? if [[ ${GREP_RC} -eq 0 ]] ; then echo "Using OLCF Gitlab registry login credentials" - docker login code.ornl.gov:4567 -u ${GITLAB_READONLY_USERNAME} -p ${GITLAB_READONLY_TOKEN} + docker login code.ornl.gov:4567 -u ${GITLAB_READONLY_USERNAME} -p ${GITLAB_READONLY_TOKEN} &>"$OUT_FD" fi # provide read only access to the private olcf dockerhub repository @@ -32,21 +40,27 @@ grep 'FROM olcf/' ./container.def GREP_RC=$? if [[ ${GREP_RC} -eq 0 ]] ; then echo "Using OLCF Dockerhub registry login credentials" - docker login -u ${DOCKERHUB_READONLY_USERNAME} -p ${DOCKERHUB_READONLY_TOKEN} + docker login -u ${DOCKERHUB_READONLY_USERNAME} -p ${DOCKERHUB_READONLY_TOKEN} &>"$OUT_FD" fi + # Spin up local registry -docker ${DEBUG_FLAG} run -d -p 5000:5000 --restart=always --name registry registry:2 +docker ${DEBUG_FLAG} run -d -p 5000:5000 --restart=always --name registry registry:2 &>"$OUT_FD" # Build the Dockerfile docker image in the current directory mv ./container.def Dockerfile -docker ${DEBUG_FLAG} build -t localhost:5000/docker_image:latest . +docker ${DEBUG_FLAG} build -t localhost:5000/docker_image:latest . || { echo 'Build Failed' ; exit 1; } # Push to the local registry -docker ${DEBUG_FLAG} push localhost:5000/docker_image:latest +docker ${DEBUG_FLAG} push localhost:5000/docker_image:latest &>"$OUT_FD" # Build the singularity container from the docker image export SINGULARITY_CACHEDIR=/home/builder/.singularity export SINGULARITY_NOHTTPS=true export SINGULARITY_PULLFOLDER=/home/builder -singularity ${DEBUG_FLAG} pull --name container.simg docker://localhost:5000/docker_image:latest \ No newline at end of file +singularity ${DEBUG_FLAG} pull --name container.simg docker://localhost:5000/docker_image:latest + +# Workaround for PULLFOLDER not being respected: https://github.com/singularityware/singularity/pull/855 +if [ -e ${SINGULARITY_CACHEDIR}/container.simg ] ; then + mv ${SINGULARITY_CACHEDIR}/container.simg ./container.simg +fi \ No newline at end of file