2017-06-27 21:37:00 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Builds a SimDem container.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
2017-07-05 03:36:58 +03:00
|
|
|
# build.sh - builds both containers (cli and novnc)
|
|
|
|
# build.sh novnc - builds the novnc version of the container
|
|
|
|
# build.sh cli - builds the CLI version of the container
|
2017-06-27 21:37:00 +03:00
|
|
|
|
|
|
|
REPOSITORY=rgardler
|
2017-07-01 08:18:38 +03:00
|
|
|
FLAVOR=${1:-}
|
2017-08-03 18:19:09 +03:00
|
|
|
IMAGE_NAME_PREFIX=simdem_
|
2017-06-27 21:37:00 +03:00
|
|
|
|
2017-08-08 00:26:56 +03:00
|
|
|
VERSION=`grep SIMDEM_VERSION config.py | awk '{print $3}' | tr -d '"'`
|
2017-06-27 21:37:00 +03:00
|
|
|
|
2017-08-03 18:15:08 +03:00
|
|
|
build_container() {
|
2017-08-03 18:19:09 +03:00
|
|
|
docker build -f Dockerfile_$1 -t $REPOSITORY/${IMAGE_NAME_PREFIX}$1:$VERSION .
|
2017-08-03 18:15:08 +03:00
|
|
|
|
|
|
|
if [ $? -eq 0 ]; then
|
2017-08-03 18:19:09 +03:00
|
|
|
echo "Built $REPOSITORY/${IMAGE_NAME_PREFIX}$1:$VERSION"
|
2017-07-03 08:48:59 +03:00
|
|
|
else
|
2017-08-03 18:19:09 +03:00
|
|
|
echo "Failed to build $REPOSITORY/${IMAGE_NAME_PREFIX}$1:$VERSION"
|
2017-08-03 18:15:08 +03:00
|
|
|
return 0
|
2017-07-03 08:48:59 +03:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-07-01 08:18:38 +03:00
|
|
|
if [[ $FLAVOR == "novnc" ]]; then
|
2017-08-03 18:15:08 +03:00
|
|
|
build_container novnc
|
2017-07-01 08:18:38 +03:00
|
|
|
elif [[ $FLAVOR == "cli" ]]; then
|
2017-08-03 18:15:08 +03:00
|
|
|
build_container cli
|
2017-07-01 08:18:38 +03:00
|
|
|
else
|
2017-08-03 18:15:08 +03:00
|
|
|
build_container cli
|
2017-08-08 05:04:10 +03:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Building container failed. Exiting"
|
2017-08-08 05:32:44 +03:00
|
|
|
return 1
|
2017-08-03 18:15:08 +03:00
|
|
|
fi
|
|
|
|
build_container novnc
|
|
|
|
fi
|
|
|
|
|
2017-08-08 20:05:10 +03:00
|
|
|
exit $?
|