Updates docs for SR1 with final revision
[genesis.git] / fuel / build / docker / runcontext
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # stefan.k.berg@ericsson.com
5 # jonas.bjurel@ericsson.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11 #
12 context=$1
13 shift
14 GID=`id -g`
15 USER=`whoami`
16 res=`docker build -q --rm -  <<EOF
17 FROM $context
18 RUN date || date
19 RUN /root/setcontext $USER $UID $GID $HOME
20 EOF`
21 GITROOT=`git rev-parse --show-toplevel`
22 CID=`echo $res | sed 's/.* //'`
23
24     RUN_CONTEXT_OPT="--privileged=true --rm -i -e HOME=$HOME -u $USER -w $PWD -v ${HOME}/.ssh:${HOME}/.ssh -v $GITROOT:$GITROOT"
25
26 if [  "${INTERACTIVE}" != "FALSE" ]; then
27     RUN_CONTEXT_OPT+=" -t"
28 fi
29
30 echo command: docker run ${RUN_CONTEXT_OPT} $CID "$@"
31 docker run ${RUN_CONTEXT_OPT} $CID "$@"
32
33 rc=$?
34 docker rmi -f $CID > /dev/null
35 exit $rc