diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-04-17 17:57:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-04-17 17:57:35 +0000 |
commit | 3b95e5be69c199a2a195c57aba12d88c242225ac (patch) | |
tree | 137b72ffaefe7f34bf21e975ccc9cc9ec0474564 /packaging/docker/build.sh | |
parent | Adding upstream version 1.13.0. (diff) | |
download | netdata-3b95e5be69c199a2a195c57aba12d88c242225ac.tar.xz netdata-3b95e5be69c199a2a195c57aba12d88c242225ac.zip |
Adding upstream version 1.14.0~rc0.upstream/1.14.0_rc0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging/docker/build.sh')
-rwxr-xr-x | packaging/docker/build.sh | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/packaging/docker/build.sh b/packaging/docker/build.sh new file mode 100755 index 00000000..3a4bd576 --- /dev/null +++ b/packaging/docker/build.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# Cross-arch docker build helper script +# +# Copyright: SPDX-License-Identifier: GPL-3.0-or-later +# +# Author : Pawel Krupa (paulfantom) +# Author : Pavlos Emm. Katsoulakis (paul@netdata.cloud) + +set -e + +if [ "${BASH_VERSINFO[0]}" -lt "4" ]; then + echo "This mechanism currently can only run on BASH version 4 and above" + exit 1 +fi + +VERSION="$1" +REPOSITORY="${REPOSITORY:-netdata}" +declare -A ARCH_MAP +ARCH_MAP=(["i386"]="386" ["amd64"]="amd64" ["armhf"]="arm" ["aarch64"]="arm64") +DEVEL_ARCHS=(amd64) +ARCHS="${!ARCH_MAP[@]}" + +# When development mode is set, build on DEVEL_ARCHS +if [ ! -z ${DEVEL+x} ]; then + declare -a ARCHS=(${DEVEL_ARCHS[@]}) +fi + +# Ensure there is a version, the most appropriate one +if [ "${VERSION}" == "" ]; then + VERSION=$(git tag --points-at) + if [ "${VERSION}" == "" ]; then + VERSION="latest" + fi +fi + +# If we are not in netdata git repo, at the top level directory, fail +TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)") +CWD=$(git rev-parse --show-cdup) +if [ ! -z $CWD ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then + echo "Run as ./packaging/docker/$(basename "$0") from top level directory of netdata git repository" + echo "Docker build process aborted" + exit 1 +fi + +echo "Docker image build in progress.." +echo "Version : ${VERSION}" +echo "Repository : ${REPOSITORY}" +echo "Architectures : ${ARCHS[*]}" + +docker run --rm --privileged multiarch/qemu-user-static:register --reset + +# Build images using multi-arch Dockerfile. +for ARCH in ${ARCHS[@]}; do + TAG="${REPOSITORY}:${VERSION}-${ARCH}" + echo "Building tag ${TAG}.." + eval docker build \ + --build-arg ARCH="${ARCH}" \ + --tag "${TAG}" \ + --file packaging/docker/Dockerfile ./ + echo "..Done!" +done + +echo "Docker build process completed!" |