Starting point for ODL Integration
[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 docker run --privileged=true --rm -i -e HOME=$HOME -u $USER -w $PWD -v ${HOME}/.ssh:${HOME}/.ssh -v $GITROOT:$GITROOT $CID "$@"
24 rc=$?
25 docker rmi $CID > /dev/null
26 exit $rc