aboutsummaryrefslogtreecommitdiffstats
path: root/fuel/build/docker/runcontext
diff options
context:
space:
mode:
authorStefan K. Berg <stefan.k.berg@ericsson.com>2015-10-19 16:52:34 +0200
committerStefan K. Berg <stefan.k.berg@ericsson.com>2015-10-26 16:24:10 +0100
commit0635291a88dd006e15224169524a7fc761ad47ab (patch)
tree05109743abecf67648fccd8ac3ce06029520828d /fuel/build/docker/runcontext
parenta890c03a1bf0ebdd19cf8c2dfdf3bc19a2391fc7 (diff)
Support for building Fuel behind a http proxy
The build system is now able to work also behind a traditional web proxy setup if the http_proxy, https_proxy and (if needed) no_proxy environment variables has been set prior to invoking make. This is a joint work by Gillian Dunne <gillian.dunne@intel.com> and Stefan Berg <stefan.k.berg@ericsson.com>. Verification so far has been with a mock setup, placing the build machine behind a Squid proxy and blocking outgoing traffic not going through the proxy by firewall rules. The following environment variables was set in the host for these tests: RSYNC_PROXY=10.0.0.1:8888 http_proxy=http://10.0.0.1:8888 https_proxy=http://10.0.0.1:8888 no_proxy=localhost,127.0.0.1,.consultron.com,.sock *** IMPORTANT NOTE ABOUT THE HOST PROXY SETTINGS *** The build system will make use the following proxy environment variables: http_proxy: https_proxy no_proxy RSYNC_PROXY RSYNC_CONNECT_PROG During the build phase, a local Ubuntu package repository is fetched from upstream in order to be added to the OPNFV Fuel ISO and for parts of this process rsync is used. This will require that either RSYNC_PROXY is set according to the format "<proxy host>:<proxy port>" and that the proxy indicated indeed allows rsync traffic *or* that RSYNC_CONNECT_PROG is set to use an alternative transport. For a detailed explanation of these settings, see the rsync manual page. *** IMPORTANT NOTE ABOUT THE HOST DOCKER DAEMON SETTINGS *** The Docker daemon on the host must be configured to use the http proxy for it to be able to pull the base Ubuntu 14.04 image from the Docker registry before invoking make! In Ubuntu this is done by adding a line like: export http_proxy="http://10.0.0.1:8888/" to /etc/default/docker and restarting the Docker daemon. Change-Id: Ieed2269af295d90a4b33d834f723889bdf9c7dc6 Signed-off-by: Stefan K. Berg <stefan.k.berg@ericsson.com>
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
+