From: Matthew Newton Date: Thu, 14 Dec 2017 21:43:46 +0000 (+0000) Subject: update dockerbuild script X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60b7f58ffd9ded89c901e3045fbd2a7dd9ae6d77;p=thirdparty%2Ffreeradius-server.git update dockerbuild script --- diff --git a/scripts/docker/dockerbuild b/scripts/docker/dockerbuild index 33ebac50579..fb3be4fd382 100755 --- a/scripts/docker/dockerbuild +++ b/scripts/docker/dockerbuild @@ -6,24 +6,65 @@ # Example usage: ./dockerbuild build-debian9 # +usage () +{ + [ "0$1" -gt 0 ] && exec 1>&2 + echo "Syntax: $0 [options] " + echo " -c disable docker cache" + echo " -j build jenkins image instead of main image" + echo " -l build with clang rather than gcc" + echo " -h this help" + exit $1 +} + +OPT_CACHE= +OPT_JENKINS= +OPT_CC=gcc +while getopts "chjl" OPT +do + case $OPT in + c) OPT_CACHE="--no-cache";; + h) usage 0;; + j) OPT_JENKINS=1;; + l) OPT_CC=clang;; + *) usage 1;; + esac +done +shift $(expr $OPTIND - 1) + DIR="$1" -[ -z "$DIR" ] && echo "Syntax: $0 " && exit 1 +[ -z "$DIR" ] && usage 1 [ ! -d "$DIR" ] && echo "Directory '$DIR' does not exist" && exit 1 +# +# Work out which OS to base our image on from the dir name +# +DIR=$(echo "$DIR" | sed -e 's/\/$//') OSNAME=$(echo "$DIR" | sed -e 's/^build-//') +# +# Build dependency image with compiler and all source ready to go +# [ ! -r "$DIR/Dockerfile.deps" ] && echo "'$DIR/Dockerfile.deps' does not exist" && exit 1 echo Building $OSNAME source and dependency image -docker build "$DIR" -f "$DIR/Dockerfile.deps" -t freeradius/$OSNAME-deps - -if [ -r "$DIR/Dockerfile.jenkins" ]; then - echo Building $OSNAME jenkins image - docker build "$DIR" -f "$DIR/Dockerfile.jenkins" -t freeradius/$OSNAME-jenkins -fi +docker build $OPT_CACHE "$DIR" -f "$DIR/Dockerfile.deps" -t freeradius/$OSNAME-deps -if [ -r "$DIR/Dockerfile" ]; then - echo Building $OSNAME FreeRADIUS image - docker build "$DIR" -t freeradius/$OSNAME +if [ -n "$OPT_JENKINS" ]; then + # + # Build jenkins image + # + if [ -r "$DIR/Dockerfile.jenkins" ]; then + echo Building $OSNAME jenkins image + docker build $OPT_CACHE "$DIR" -f "$DIR/Dockerfile.jenkins" -t freeradius/$OSNAME-jenkins + fi +else + # + # Build main image + # + if [ -r "$DIR/Dockerfile" ]; then + echo Building $OSNAME FreeRADIUS image + docker build --build-arg=cc=$OPT_CC $OPT_CACHE "$DIR" -t freeradius/$OSNAME + fi fi