summaryrefslogtreecommitdiffstats
path: root/docker/build.sh
blob: 7a3e50dc5f32f317819595e653a48d5deb47b154 (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
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+
# author  : paulfantom
# Cross-arch docker build helper script

set +e

REPOSITORY="${REPOSITORY:-netdata}"

if [ ${VERSION+x} ]; then
    VERSION="-${VERSION}"
else
    VERSION=""
fi

docker run --rm --privileged multiarch/qemu-user-static:register --reset

if [ -f Dockerfile ]; then
    cd ../ || exit 1
fi

for ARCH in i386 armhf aarch64 amd64; do
     docker build --build-arg ARCH="${ARCH}-v3.8" --tag "${REPOSITORY}:${ARCH}${VERSION}" --file docker/Dockerfile ./
done
docker tag "${REPOSITORY}:${ARCH}${VERSION}" "${REPOSITORY}:latest"

# Push images to registry
if [ -z ${DOCKER_USERNAME+x} ]; then
    echo "No docker hub username  specified. Exiting without pushing images to registry"
    exit 1
fi
if [ -z ${DOCKER_PASSWORD+x} ]; then
    echo "No docker hub password specified. Exiting without pushing images to registry"
    exit 1
fi
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
for ARCH in amd64 i386 armhf aarch64; do
    docker push "${REPOSITORY}:${ARCH}${VERSION}"
done
docker push "${REPOSITORY}:latest"

# TODO: Remove it after we decide to deprecate firehol/netdata docker repo
if [ "$REPOSITORY" != "netdata" ]; then
    echo "$OLD_DOCKER_PASSWORD" | docker login -u "$OLD_DOCKER_USERNAME" --password-stdin   
    for ARCH in amd64 i386 armhf aarch64; do
        docker tag ${REPOSITORY}:${ARCH}${VERSION} firehol/netdata:${ARCH}${VERSION}
        docker push "firehol/netdata:${ARCH}${VERSION}"
    done
    docker tag "${REPOSITORY}:latest" "firehol/netdata:latest"
    docker push "firehol/netdata:latest"
fi