Adds Docker based build system for Binary Packages, CI/CD, Smoke Testing and Development. (#7735)
* Added Dockerfile for building, packaging and performing basic smoke tests of the package(s) and NetData Agent itself * Moved install of package per distro into a script and refactor in order to supprot other distro(s) * Add support for RPM based systems too (Fedora, CentOS) * Drop the unnecessary (for now) Debian cleanup steps * Reverse the order of installing NetData agent and testing tools * Update default VERSION to 0.1 to match builder images * Added support for openSUSE * Minor fixes from review * Update Dockerfile Co-Authored-By: Austin S. Hemmelgarn <ahferroin7@gmail.com> * Update Dockerfile Co-Authored-By: Austin S. Hemmelgarn <ahferroin7@gmail.com> * Move thigns around a bit * Re-update test/install shell scripts to be POSIX. We don't really want to depend on Bash here * Fixed support for yum vs. dnf * Fixed paths to scripts * Added a script to kick off the build/package/install/test flow more easily for both humans and CI/CD Co-authored-by: Austin S. Hemmelgarn <ahferroin7@gmail.com>
This commit is contained in:
parent
cb7f19ba2d
commit
d307ba7ec5
|
@ -0,0 +1 @@
|
|||
.gitignore
|
|
@ -0,0 +1,42 @@
|
|||
ARG ARCH=amd64
|
||||
ARG DISTRO=debian
|
||||
ARG DISTRO_VERSION=10
|
||||
ARG VERSION=0.1
|
||||
|
||||
FROM netdata/package-builders:${DISTRO}${DISTRO_VERSION} AS build
|
||||
|
||||
ARG ARCH
|
||||
ARG DISTRO
|
||||
ARG DISTRO_VERSION
|
||||
ARG VERSION
|
||||
|
||||
ENV ARCH=$ARCH
|
||||
ENV DISTRO=$DISTRO
|
||||
ENV DISTRO_VERSION=$DISTRO_VERSION
|
||||
ENV VERSION=$VERSION
|
||||
|
||||
WORKDIR /netdata
|
||||
COPY . .
|
||||
|
||||
RUN /build.sh
|
||||
|
||||
FROM ${DISTRO}:${DISTRO_VERSION} AS runtime
|
||||
|
||||
ARG ARCH
|
||||
ARG DISTRO
|
||||
ARG DISTRO_VERSION
|
||||
ARG VERSION
|
||||
|
||||
ENV ARCH=$ARCH
|
||||
ENV DISTRO=$DISTRO
|
||||
ENV DISTRO_VERSION=$DISTRO_VERSION
|
||||
ENV VERSION=$VERSION
|
||||
|
||||
COPY ./packaging/scripts/install.sh /install.sh
|
||||
COPY ./packaging/scripts/test.sh /test.sh
|
||||
|
||||
COPY --from=build /netdata/artifacts /artifacts
|
||||
|
||||
RUN /install.sh
|
||||
|
||||
CMD ["/test.sh"]
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
set -e
|
||||
|
||||
# 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 || echo "")
|
||||
if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" = "netdata" ]; then
|
||||
echo "Run as ./packaging/$(basename "$0") from top level directory of netdata git repository"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
|
||||
echo "Usage: ./packaging/$(basename "$0") <distro> <distro_version> [<netdata_version>]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v docker > /dev/null; then
|
||||
echo "Docker CLI not found. You need Docker to run this!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
DISTRO="$1"
|
||||
DISTRO_VERSION="$2"
|
||||
# TODO: Auto compute this?
|
||||
VERSION="${3:-1.19.0}"
|
||||
|
||||
TAG="netdata/netdata:${DISTRO}_${DISTRO_VERSION}"
|
||||
|
||||
docker build \
|
||||
-f ./packaging/Dockerfile.packager \
|
||||
--build-arg DISTRO="$DISTRO" \
|
||||
--build-arg DISTRO_VERSION="$DISTRO_VERSION" \
|
||||
--build-arg VERSION="$VERSION" \
|
||||
-t "$TAG" . |
|
||||
tee build.log
|
|
@ -0,0 +1,58 @@
|
|||
#!/bin/sh
|
||||
|
||||
install_debian_like() {
|
||||
# This is needed to ensure package installs don't prompt for any user input.
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
apt-get update
|
||||
|
||||
# Install NetData
|
||||
apt-get install -y "/artifacts/netdata_${VERSION}_${ARCH}.deb"
|
||||
|
||||
# Install testing tools
|
||||
apt-get install -y --no-install-recommends \
|
||||
curl netcat jq
|
||||
}
|
||||
|
||||
install_fedora_like() {
|
||||
# Using a glob pattern here because I can't reliably determine what the
|
||||
# resulting package name will be (TODO: There must be a better way!)
|
||||
|
||||
PKGMGR="$( (command -v dnf > /dev/null && echo "dnf") || echo "yum")"
|
||||
|
||||
# Install NetData
|
||||
"$PKGMGR" install -y /artifacts/netdata-"${VERSION}"-*.rpm
|
||||
|
||||
# Install testing tools
|
||||
"$PKGMGR" install -y curl nc jq
|
||||
}
|
||||
|
||||
install_suse_like() {
|
||||
# Using a glob pattern here because I can't reliably determine what the
|
||||
# resulting package name will be (TODO: There must be a better way!)
|
||||
|
||||
# Install NetData
|
||||
# FIXME: Allow unsigned packages (for now) #7773
|
||||
zypper install -y --allow-unsigned-rpm \
|
||||
/artifacts/netdata-"${VERSION}"-*.rpm
|
||||
|
||||
# Install testing tools
|
||||
zypper install -y --no-recommends \
|
||||
curl netcat jq
|
||||
}
|
||||
|
||||
case "${DISTRO}" in
|
||||
debian | ubuntu)
|
||||
install_debian_like
|
||||
;;
|
||||
fedora | centos)
|
||||
install_fedora_like
|
||||
;;
|
||||
opensuse)
|
||||
install_suse_like
|
||||
;;
|
||||
*)
|
||||
printf "ERROR: unspported distro: %s_%s\n" "${DISTRO}" "${DISTRO_VERSION}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
|
||||
wait_for() {
|
||||
host="${1}"
|
||||
port="${2}"
|
||||
name="${3}"
|
||||
timeout="${4:-30}"
|
||||
|
||||
printf "Waiting for %s on %s:%s ... " "${name}" "${host}" "${port}"
|
||||
|
||||
i=0
|
||||
while ! nc -z "${host}" "${port}"; do
|
||||
sleep 1
|
||||
if [ "$i" -gt "$timeout" ]; then
|
||||
printf "Timed out!\n"
|
||||
return 1
|
||||
fi
|
||||
i="$((i + 1))"
|
||||
done
|
||||
printf "OK\n"
|
||||
}
|
||||
|
||||
netdata -D > netdata.log 2>&1 &
|
||||
|
||||
wait_for localhost 19999 netdata
|
||||
|
||||
curl -sS http://127.0.0.1:19999/api/v1/info | jq '.version'
|
Loading…
Reference in New Issue