summaryrefslogtreecommitdiffstats
path: root/hack/build-images.sh
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2016-12-08 11:52:30 -0500
committerBrenton Leanhardt <bleanhar@redhat.com>2017-03-07 15:51:15 -0500
commit77441837777312dbed93fe98f0058501bd6aefbd (patch)
treeb69a802d392f05897114b276b769f18aed9db66f /hack/build-images.sh
parented103af9a9fb6f99f4c2f4d040649698d67eb6b0 (diff)
downloadopenshift-77441837777312dbed93fe98f0058501bd6aefbd.tar.gz
openshift-77441837777312dbed93fe98f0058501bd6aefbd.tar.bz2
openshift-77441837777312dbed93fe98f0058501bd6aefbd.tar.xz
openshift-77441837777312dbed93fe98f0058501bd6aefbd.zip
Adding scripts for building and pushing images
These scripts follow the same pattern as the origin and origin-metrics repo. From there the Jenkins job will be very simple.
Diffstat (limited to 'hack/build-images.sh')
-rwxr-xr-xhack/build-images.sh87
1 files changed, 87 insertions, 0 deletions
diff --git a/hack/build-images.sh b/hack/build-images.sh
new file mode 100755
index 000000000..f6210e239
--- /dev/null
+++ b/hack/build-images.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+STARTTIME=$(date +%s)
+source_root=$(dirname "${0}")/..
+
+prefix="openshift/openshift-ansible"
+version="latest"
+verbose=false
+options=""
+help=false
+
+for args in "$@"
+do
+ case $args in
+ --prefix=*)
+ prefix="${args#*=}"
+ ;;
+ --version=*)
+ version="${args#*=}"
+ ;;
+ --no-cache)
+ options="${options} --no-cache"
+ ;;
+ --verbose)
+ verbose=true
+ ;;
+ --help)
+ help=true
+ ;;
+ esac
+done
+
+# allow ENV to take precedent over switches
+prefix="${PREFIX:-$prefix}"
+version="${OS_TAG:-$version}"
+
+if [ "$help" = true ]; then
+ echo "Builds the docker images for openshift-ansible"
+ echo
+ echo "Options: "
+ echo " --prefix=PREFIX"
+ echo " The prefix to use for the image names."
+ echo " default: openshift/openshift-ansible"
+ echo
+ echo " --version=VERSION"
+ echo " The version used to tag the image"
+ echo " default: latest"
+ echo
+ echo " --no-cache"
+ echo " If set will perform the build without a cache."
+ echo
+ echo " --verbose"
+ echo " Enables printing of the commands as they run."
+ echo
+ echo " --help"
+ echo " Prints this help message"
+ echo
+ exit 0
+fi
+
+if [ "$verbose" = true ]; then
+ set -x
+fi
+
+BUILD_STARTTIME=$(date +%s)
+comp_path=$source_root/
+docker_tag=${prefix}:${version}
+echo
+echo
+echo "--- Building component '$comp_path' with docker tag '$docker_tag' ---"
+docker build ${options} -t $docker_tag $comp_path
+BUILD_ENDTIME=$(date +%s); echo "--- $docker_tag took $(($BUILD_ENDTIME - $BUILD_STARTTIME)) seconds ---"
+echo
+echo
+
+echo
+echo
+echo "++ Active images"
+docker images | grep ${prefix} | grep ${version} | sort
+echo
+
+
+ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"