Commit 7e232d5c authored by AdamSimpson's avatar AdamSimpson
Browse files

Don't unbuffer if client doesn't have a tty

parent f0683c6c
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -2,13 +2,17 @@

source /home/builder/environment.sh

# Test for any arguments, such as --debug
# Test for any arguments
for i in "$@"
do
case ${i} in
    --debug)
    DEBUG_FLAG='--debug'
    shift # past argument with no value
    shift
    ;;
    --tty)
    TTY='/usr/bin/unbuffer'
    shift
    ;;
    *)
      echo "unknown argument to singularity-builder-backend.sh"
@@ -45,13 +49,13 @@ docker ${DEBUG_FLAG} run -d -p 5000:5000 --restart=always --name registry regist

# Build the Dockerfile docker image in the current directory
mv ./container.def Dockerfile
/usr/bin/unbuffer /usr/bin/docker ${DEBUG_FLAG} build -t localhost:5000/docker_image:latest . || { echo 'Build Failed' ; exit 1; }
${TTY} /usr/bin/docker ${DEBUG_FLAG} build -t localhost:5000/docker_image:latest . || { echo 'Build Failed' ; exit 1; }

# Push to the local registry
/usr/bin/unbuffer /usr/bin/docker ${DEBUG_FLAG} push localhost:5000/docker_image:latest
${TTY} /usr/bin/docker ${DEBUG_FLAG} push localhost:5000/docker_image:latest

# Build the singularity container from the docker image
export SINGULARITY_CACHEDIR=/home/builder/.singularity
export SINGULARITY_NOHTTPS=true # Needed as we're pulling from localhost
export SINGULARITY_PULLFOLDER=/home/builder
/usr/bin/unbuffer /usr/local/bin/singularity ${DEBUG_FLAG} build container.simg docker://localhost:5000/docker_image:latest
 No newline at end of file
${TTY} /usr/local/bin/singularity ${DEBUG_FLAG} build container.simg docker://localhost:5000/docker_image:latest
 No newline at end of file
+7 −3
Original line number Diff line number Diff line
@@ -2,13 +2,17 @@

source /home/builder/environment.sh

# Test for any arguments, such as --debug
# Test for any arguments
for i in "$@"
do
case ${i} in
    --debug)
    DEBUG_FLAG='--debug'
    shift # past argument with no value
    shift
    ;;
    --tty)
    TTY='/usr/bin/unbuffer'
    shift
    ;;
    *)
      echo "unknown argument to singularity-builder-backend.sh"
@@ -36,4 +40,4 @@ if [[ ${GREP_RC} -eq 0 ]] ; then
fi

export SINGULARITY_CACHEDIR=/home/builder/.singularity
/usr/bin/unbuffer /usr/local/bin/singularity ${DEBUG_FLAG} build ./container.simg ./container.def
 No newline at end of file
${TTY} /usr/local/bin/singularity ${DEBUG_FLAG} build ./container.simg ./container.def
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -92,6 +92,11 @@ std::string build_command(const ClientData &client_data) {
        build_command += " --debug";
    }

    // Enable pseudo tty
    if (client_data.tty) {
        build_command += " --tty";
    }

    Logger::info("Build command prepared: " + build_command);

    return build_command;