Mercurial > public > mercurial-scm > hg
diff 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 |
line wrap: on
line diff
--- a/contrib/dockerlib.sh Wed May 06 10:45:07 2015 -0400 +++ b/contrib/dockerlib.sh Wed May 06 10:45:51 2015 -0400 @@ -17,3 +17,19 @@ $DOCKER version | grep -q "^Client version:" || { echo "Error: unexpected output from \"$DOCKER version\""; exit 1; } $DOCKER version | grep -q "^Server version:" || { echo "Error: could not get docker server version - check it is running and your permissions"; exit 1; } } + +# Construct a container and leave its name in $CONTAINER for future use. +function initcontainer() { + [ "$1" ] || { echo "Error: platform name must be specified"; exit 1; } + + DFILE="$ROOTDIR/contrib/docker/$1" + [ -f "$DFILE" ] || { echo "Error: docker file $DFILE not found"; exit 1; } + + CONTAINER="hg-dockerrpm-$1" + DBUILDUSER=build + ( + cat $DFILE + echo RUN groupadd $DBUILDUSER -g `id -g` + echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER + ) | $DOCKER build --tag $CONTAINER - +}