comparison contrib/dockerlib.sh @ 24969:227b9b2a57a3

dockerlib: extract initcontainer() method This helps contain all the logic around creating containers.
author Augie Fackler <augie@google.com>
date Wed, 06 May 2015 10:45:51 -0400
parents 80c9e99d68e0
children 33055069e465
comparison
equal deleted inserted replaced
24968:80c9e99d68e0 24969:227b9b2a57a3
15 15
16 $DOCKER -h 2> /dev/null | grep -q Jansens && { echo "Error: $DOCKER is the Docking System Tray - install docker.io instead"; exit 1; } 16 $DOCKER -h 2> /dev/null | grep -q Jansens && { echo "Error: $DOCKER is the Docking System Tray - install docker.io instead"; exit 1; }
17 $DOCKER version | grep -q "^Client version:" || { echo "Error: unexpected output from \"$DOCKER version\""; exit 1; } 17 $DOCKER version | grep -q "^Client version:" || { echo "Error: unexpected output from \"$DOCKER version\""; exit 1; }
18 $DOCKER version | grep -q "^Server version:" || { echo "Error: could not get docker server version - check it is running and your permissions"; exit 1; } 18 $DOCKER version | grep -q "^Server version:" || { echo "Error: could not get docker server version - check it is running and your permissions"; exit 1; }
19 } 19 }
20
21 # Construct a container and leave its name in $CONTAINER for future use.
22 function initcontainer() {
23 [ "$1" ] || { echo "Error: platform name must be specified"; exit 1; }
24
25 DFILE="$ROOTDIR/contrib/docker/$1"
26 [ -f "$DFILE" ] || { echo "Error: docker file $DFILE not found"; exit 1; }
27
28 CONTAINER="hg-dockerrpm-$1"
29 DBUILDUSER=build
30 (
31 cat $DFILE
32 echo RUN groupadd $DBUILDUSER -g `id -g`
33 echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER
34 ) | $DOCKER build --tag $CONTAINER -
35 }