summaryrefslogtreecommitdiffstats
path: root/packaging/docker/build-test.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-09-13 05:05:16 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-09-13 05:05:16 +0000
commit8f5d8f3de6cae180af37917ef978a4affc2cd464 (patch)
tree4bfe1abc6d19c2dd635d1b83cc0e73d0aa6904ac /packaging/docker/build-test.sh
parentAdding upstream version 1.17.0. (diff)
downloadnetdata-8f5d8f3de6cae180af37917ef978a4affc2cd464.tar.xz
netdata-8f5d8f3de6cae180af37917ef978a4affc2cd464.zip
Adding upstream version 1.17.1.upstream/1.17.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging/docker/build-test.sh')
-rwxr-xr-xpackaging/docker/build-test.sh74
1 files changed, 74 insertions, 0 deletions
diff --git a/packaging/docker/build-test.sh b/packaging/docker/build-test.sh
new file mode 100755
index 000000000..3c55e1736
--- /dev/null
+++ b/packaging/docker/build-test.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+# Docker build wrapper, for testing manually the docker build process
+# TODO: This script should consume build.sh after setting up required parameters
+#
+# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Author : Chris Akritidis (chris@netdata.cloud)
+# Author : Pavlos Emm. Katsoulakis (paul@netdata.cloud)
+
+printhelp() {
+ echo "Usage: packaging/docker/build-test.sh -r <REPOSITORY> -v <VERSION> -u <DOCKER_USERNAME> -p <DOCKER_PWD> [-s]
+ -s skip build, just push the image
+Builds an amd64 image and pushes it to the docker hub repository REPOSITORY"
+}
+
+set -e
+
+if [ ! -f .gitignore ]; then
+ echo "Run as ./packaging/docker/$(basename "$0") from top level directory of git repository"
+ exit 1
+fi
+
+DOBUILD=1
+while getopts :r:v:u:p:s option
+do
+ case "$option" in
+ r)
+ REPOSITORY=$OPTARG
+ ;;
+ v)
+ VERSION=$OPTARG
+ ;;
+ u)
+ DOCKER_USERNAME=$OPTARG
+ ;;
+ p)
+ DOCKER_PWD=$OPTARG
+ ;;
+ s)
+ DOBUILD=0
+ ;;
+ *)
+ printhelp
+ exit 1
+ ;;
+ esac
+done
+
+if [ -n "${REPOSITORY}" ]; then
+ if [ $DOBUILD -eq 1 ] ; then
+ echo "Building ${VERSION:-latest} of ${REPOSITORY} container"
+ docker run --rm --privileged multiarch/qemu-user-static:register --reset
+
+ # Build images using multi-arch Dockerfile.
+ eval docker build --build-arg ARCH="amd64" --tag "${REPOSITORY}:${VERSION:-latest}" --file packaging/docker/Dockerfile ./
+
+ # Create temporary docker CLI config with experimental features enabled (manifests v2 need it)
+ mkdir -p /tmp/docker
+ #echo '{"experimental":"enabled"}' > /tmp/docker/config.json
+ fi
+
+ if [ -n "${DOCKER_USERNAME}" ] && [ -n "${DOCKER_PWD}" ] ; then
+ # Login to docker hub to allow futher operations
+ echo "Logging into docker"
+ echo "$DOCKER_PWD" | docker --config /tmp/docker login -u "$DOCKER_USERNAME" --password-stdin
+
+ echo "Pushing ${REPOSITORY}:${VERSION}"
+ docker --config /tmp/docker push "${REPOSITORY}:${VERSION}"
+ fi
+else
+ echo "Missing parameter. REPOSITORY=${REPOSITORY}"
+ printhelp
+ exit 1
+fi