blob: 456114b3180a28eb9fe2ed7347f0df81866e8970 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/usr/bin/env bash
#
#
# 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"
declare -A ARCH_MAP
ARCH_MAP=(["i386"]="386" ["amd64"]="amd64" ["armhf"]="arm" ["aarch64"]="arm64")
DEVEL_ARCHS=(amd64)
[ "${ARCHS}" ] || ARCHS="${!ARCH_MAP[@]}" # Use default ARCHS unless ARCHS are externally provided
if [ -z ${REPOSITORY} ]; then
REPOSITORY="${TRAVIS_REPO_SLUG}"
if [ -z ${REPOSITORY} ]; then
echo "REPOSITORY not set, build cannot proceed"
exit 1
else
echo "REPOSITORY was not detected, attempted to use TRAVIS_REPO_SLUG setting: ${TRAVIS_REPO_SLUG}"
fi
fi
# 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 --no-cache \
--build-arg ARCH="${ARCH}" \
--tag "${TAG}" \
--file packaging/docker/Dockerfile ./
echo "..Done!"
done
echo "Docker build process completed!"
|