summaryrefslogtreecommitdiffstats
path: root/packaging/docker/build.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xpackaging/docker/build.sh (renamed from docker/build.sh)47
1 files changed, 28 insertions, 19 deletions
diff --git a/docker/build.sh b/packaging/docker/build.sh
index faaa2db7..6958f05e 100755
--- a/docker/build.sh
+++ b/packaging/docker/build.sh
@@ -6,6 +6,11 @@
set -e
+if [ ! -f .gitignore ]; then
+ echo "Run as ./packaging/docker/$(basename "$0") from top level directory of git repository"
+ exit 1
+fi
+
if [ "$1" == "" ]; then
VERSION=$(git tag --points-at)
else
@@ -15,36 +20,41 @@ if [ "${VERSION}" == "" ]; then
VERSION="latest"
fi
-REPOSITORY="${REPOSITORY:-netdata}"
-
-echo "Building $VERSION of netdata container"
-
declare -A ARCH_MAP
ARCH_MAP=( ["i386"]="386" ["amd64"]="amd64" ["armhf"]="arm" ["aarch64"]="arm64")
+if [ -z ${DEVEL+x} ]; then
+ declare -a ARCHITECTURES=(i386 armhf aarch64 amd64)
+else
+ declare -a ARCHITECTURES=(amd64)
+ unset DOCKER_PASSWORD
+ unset DOCKER_USERNAME
+fi
-docker run --rm --privileged multiarch/qemu-user-static:register --reset
+REPOSITORY="${REPOSITORY:-netdata}"
+echo "Building ${VERSION} of ${REPOSITORY} container"
-if [ -f Dockerfile ]; then
- cd ../ || exit 1
-fi
+docker run --rm --privileged multiarch/qemu-user-static:register --reset
# Build images using multi-arch Dockerfile.
-for ARCH in i386 armhf aarch64 amd64; do
- docker build --build-arg ARCH="${ARCH}-v3.8" \
- --tag "${REPOSITORY}:${VERSION}-${ARCH}" \
- --file docker/Dockerfile ./ &
+for ARCH in "${ARCHITECTURES[@]}"; do
+ eval docker build \
+ --build-arg ARCH="${ARCH}-v3.8" \
+ --build-arg OUTPUT=/dev/null \
+ --tag "${REPOSITORY}:${VERSION}-${ARCH}" \
+ --file packaging/docker/Dockerfile ./
done
-wait
+
+# There is no reason to continue if we cannot log in to docker hub
+if [ -z ${DOCKER_USERNAME+x} ] || [ -z ${DOCKER_PASSWORD+x} ]; then
+ echo "No docker hub username or password specified. Exiting without pushing images to registry"
+ exit 0
+fi
# Create temporary docker CLI config with experimental features enabled (manifests v2 need it)
mkdir -p /tmp/docker
echo '{"experimental":"enabled"}' > /tmp/docker/config.json
-# Login to docker hub to allow for futher operations
-if [ -z ${DOCKER_USERNAME+x} ] || [ -z ${DOCKER_PASSWORD+x} ]; then
- echo "No docker hub username or password specified. Exiting without pushing images to registry"
- exit 1
-fi
+# Login to docker hub to allow futher operations
echo "$DOCKER_PASSWORD" | docker --config /tmp/docker login -u "$DOCKER_USERNAME" --password-stdin
# Push images to registry
@@ -71,4 +81,3 @@ docker --config /tmp/docker manifest push -p "${REPOSITORY}:${VERSION}"
# Show current manifest (debugging purpose only)
docker --config /tmp/docker manifest inspect "${REPOSITORY}:${VERSION}"
-