Skip to content

Commit

Permalink
Don't unbuffer if client doesn't have a tty
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSimpson committed Feb 18, 2018
1 parent f0683c6 commit 7e232d5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
14 changes: 9 additions & 5 deletions Builder/scripts/docker-builder-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
${TTY} /usr/local/bin/singularity ${DEBUG_FLAG} build container.simg docker://localhost:5000/docker_image:latest
10 changes: 7 additions & 3 deletions Builder/scripts/singularity-builder-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
${TTY} /usr/local/bin/singularity ${DEBUG_FLAG} build ./container.simg ./container.def
5 changes: 5 additions & 0 deletions Builder/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7e232d5

Please sign in to comment.