aboutsummaryrefslogtreecommitdiffstats
path: root/fuel/build/docker/runcontext
diff options
context:
space:
mode:
Diffstat (limited to 'fuel/build/docker/runcontext')
-rwxr-xr-xfuel/build/docker/runcontext48
1 files changed, 46 insertions, 2 deletions
diff --git a/fuel/build/docker/runcontext b/fuel/build/docker/runcontext
index 341612b4e..a874fb8e9 100755
--- a/fuel/build/docker/runcontext
+++ b/fuel/build/docker/runcontext
@@ -29,20 +29,57 @@ do_exit () {
# End of Exit handlers
############################################################################
+
trap do_exit SIGINT SIGTERM EXIT
+
context=$1
shift
GID=`id -g`
USER=`whoami`
res=`docker build -q --force-rm - <<EOF
FROM $context
+$(env | egrep -i 'proxy|rsync' | sed 's/^/ENV /' | sed 's/=/ /')
RUN date || date
RUN /root/setcontext $USER $UID $GID $HOME
EOF`
GITROOT=`git rev-parse --show-toplevel`
IID=`echo $res | sed 's/.* //'`
+
CID_FILE=`mktemp -u -t runcontext.XXXXXXXXXX`
+# Handle proxy settings passed to the context
+if env | grep -iq .*proxy; then
+ envfile="$(readlink -f $(dirname $0)/..)/environment.mk"
+
+ test -n "$HTTP_PROXY" && my_http_proxy=$HTTP_PROXY
+ test -n "$http_proxy" && my_http_proxy=$http_proxy
+
+ test -n "$HTTPS_PROXY" && my_https_proxy=$HTTPS_PROXY
+ test -n "$https_proxy" && my_https_proxy=$https_proxy
+
+ test -n "$NO_PROXY" && my_no_proxy=$NO_PROXY
+ test -n "$no_proxy" && my_no_proxy=$no_proxy
+
+ # Make sure to add the Docker socket in no_proxy
+ if [ -n "$my_no_proxy" ]; then
+ my_no_proxy+=",/var/run/docker.sock"
+ else
+ my_no_proxy="/var/run/docker.sock"
+ fi
+
+ echo "Creating $envfile"
+ echo "# This file is automatically generated by runcontext, do not edit!" > $envfile
+ test -n "$my_http_proxy" && echo "export http_proxy=$my_http_proxy" >> $envfile
+ test -n "$my_https_proxy" && echo "export https_proxy=$my_https_proxy" >> $envfile
+ test -n "$my_no_proxy" && echo "export no_proxy=$my_no_proxy" >> $envfile
+ test -n "$RSYNC_PROXY" && echo "export RSYNC_PROXY=$RSYNC_PROXY" >> $envfile
+ test -n "$RSYNC_CONNECT_PROG" && echo "export RSYNC_CONNECT_PROG=$RSYNC_CONNECT_PROG" >> $envfile
+ echo "export npm_config_registry=http://registry.npmjs.org/" >> $envfile
+else
+ echo "No need to generate environment.mk"
+ rm -f $envfile
+fi
+
# Evaluate the need for bind mounting the cache directory
if [ -n "$CACHEBASE" ]; then
if echo $CACHEBASE | grep -q '^file://'; then
@@ -52,5 +89,12 @@ fi
RUN_CONTEXT_OPT="--cidfile $CID_FILE --privileged=true --rm -e HOME=$HOME -e CACHEDEBUG -e CACHETRANSPORT -e CACHEMAXAGE -e CACHEBASE -u $USER -w $PWD -v ${HOME}/.ssh:${HOME}/.ssh -v $GITROOT:$GITROOT $CACHEMOUNT"
-echo command: docker run ${RUN_CONTEXT_OPT} $IID "$@"
-docker run ${RUN_CONTEXT_OPT} $IID "$@"
+# Passing "debug" puts up an interactive bash shell
+if [ "$1" == "debug" ]; then
+ echo command: docker run ${RUN_CONTEXT_OPT} $IID $@
+ docker run -i -t ${RUN_CONTEXT_OPT} $IID bash
+else
+ echo command: docker run ${RUN_CONTEXT_OPT} $IID $@
+ docker run -t ${RUN_CONTEXT_OPT} $IID $@
+fi
+