summaryrefslogtreecommitdiffstats
path: root/roles/docker_img_build/files/ops-build-container.sh
diff options
context:
space:
mode:
Diffstat (limited to 'roles/docker_img_build/files/ops-build-container.sh')
-rwxr-xr-xroles/docker_img_build/files/ops-build-container.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/roles/docker_img_build/files/ops-build-container.sh b/roles/docker_img_build/files/ops-build-container.sh
new file mode 100755
index 000000000..308fbd58c
--- /dev/null
+++ b/roles/docker_img_build/files/ops-build-container.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+RED=$(echo -e "\e[31m")
+GREEN=$(echo -e "\e[32m")
+YELLOW=$(echo -e "\e[33m")
+BLUE=$(echo -e "\e[34m")
+NORM=$(echo -e "\e[0m")
+
+CTR_DIR='/usr/local/etc/containers'
+
+EXIT_CODE=0
+
+function main()
+{
+ # Make sure we're in the directory we expect to be in
+ cd $CTR_DIR
+
+ TAG=$(echo $1 | sed 's/_container[\/]*//')
+ if [ -z "$TAG" ]
+ then
+ echo "FAILED parsing tag from \$1 [$1]"
+ exit 10
+ fi
+
+ docker build --rm -t $TAG $1
+ EXIT_CODE=$?
+}
+
+if [ $# -ne 1 ]
+then
+ echo
+ echo " Usage: $(basename $0) container"
+ echo "Example: $(basename $0) monitoring_container"
+ echo
+ exit
+fi
+
+if ! [ -d "$CTR_DIR/$1" ]
+then
+ echo "Error: directory not found [$CTR_DIR/$1]"
+ exit 10
+fi
+
+time main $@
+echo
+echo
+
+if [ $EXIT_CODE -eq 0 ]
+then
+ echo "${GREEN}$1 build succeeded.${NORM}"
+else
+ echo "${RED}$1 build FAILED!${NORM}"
+fi
+
+echo
+exit $EXIT_CODE