#! /bin/bash

# Wrapper script for `docker build'.
# This is a workaround for https://github.com/dotcloud/docker/issues/1875.

tmpfile=$(mktemp)
trap "rm $tmpfile; exit 1" SIGHUP SIGINT SIGTERM

docker build $* | tee ${tmpfile}
if $(grep -q 'Error build' ${tmpfile})
then
  result=1
else
  result=0
fi

rm $tmpfile
exit $result