| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | |
| 4 | set -e |
| 5 | |
| 6 | # If we are not in netdata git repo, at the top level directory, FAIL |
| 7 | TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)") |
| 8 | CWD=$(git rev-parse --show-cdup || echo "") |
| 9 | if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" = "netdata" ]; then |
| 10 | echo "Run as ./packaging/$(basename "$0") from top level directory of netdata git repository" |
| 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | if [ $# -lt 2 ] || [ $# -gt 3 ]; then |
| 15 | echo "Usage: ./packaging/$(basename "$0") <distro> <distro_version> [<netdata_version>]" |
| 16 | exit 1 |
| 17 | fi |
| 18 | |
| 19 | if ! command -v docker > /dev/null; then |
| 20 | echo "Docker CLI not found. You need Docker to run this!" |
| 21 | exit 2 |
| 22 | fi |
| 23 | |
| 24 | DISTRO="$1" |
| 25 | DISTRO_VERSION="$2" |
| 26 | # TODO: Auto compute this? |
| 27 | VERSION="${3:-1.19.0}" |
| 28 | |
| 29 | TAG="netdata/netdata:${DISTRO}_${DISTRO_VERSION}" |
| 30 | |
| 31 | docker build \ |
| 32 | -f ./packaging/Dockerfile.packager \ |
| 33 | --build-arg DISTRO="$DISTRO" \ |
| 34 | --build-arg DISTRO_VERSION="$DISTRO_VERSION" \ |
| 35 | --build-arg VERSION="$VERSION" \ |
| 36 | -t "$TAG" . | |
| 37 | tee build.log |