summaryrefslogtreecommitdiffstats
path: root/packaging/makeself/build-static.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/makeself/build-static.sh')
-rwxr-xr-xpackaging/makeself/build-static.sh55
1 files changed, 17 insertions, 38 deletions
diff --git a/packaging/makeself/build-static.sh b/packaging/makeself/build-static.sh
index f38353721..c7c5a4bcc 100755
--- a/packaging/makeself/build-static.sh
+++ b/packaging/makeself/build-static.sh
@@ -9,57 +9,36 @@ BUILDARCH="${1}"
set -e
-case ${BUILDARCH} in
- x86_64) platform=linux/amd64 ;;
- armv7l) platform=linux/arm/v7 ;;
- aarch64) platform=linux/arm64/v8 ;;
- ppc64le) platform=linux/ppc64le ;;
- *)
- echo "Unknown target architecture '${BUILDARCH}'."
+platform="$("$(dirname "${0}")/uname2platform.sh" "${BUILDARCH}")"
+
+if [ -z "${platform}" ]; then
exit 1
- ;;
-esac
+fi
-DOCKER_CONTAINER_NAME="netdata-package-${BUILDARCH}-static-alpine315"
+DOCKER_IMAGE_NAME="netdata/static-builder"
if [ "${BUILDARCH}" != "$(uname -m)" ] && [ "$(uname -m)" = 'x86_64' ] && [ -z "${SKIP_EMULATION}" ]; then
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes || exit 1
fi
-if ! docker inspect "${DOCKER_CONTAINER_NAME}" > /dev/null 2>&1; then
- # To run interactively:
- # docker run -it netdata-package-x86_64-static /bin/sh
- # (add -v host-dir:guest-dir:rw arguments to mount volumes)
- #
- # To remove images in order to re-create:
- # docker rm -v $(sudo docker ps -a -q -f status=exited)
- # docker rmi netdata-package-x86_64-static
- #
- # This command maps the current directory to
- # /usr/src/netdata.git
- # inside the container and runs the script install-alpine-packages.sh
- # (also inside the container)
- #
- if docker inspect alpine:3.15 > /dev/null 2>&1; then
- run docker image remove alpine:3.15
- run docker pull --platform=${platform} alpine:3.15
- fi
-
- run docker run --platform=${platform} -v "$(pwd)":/netdata:rw alpine:3.15 \
- /bin/sh /netdata/packaging/makeself/install-alpine-packages.sh
+if docker inspect "${DOCKER_IMAGE_NAME}" > /dev/null 2>&1; then
+ img_platform="$(docker image inspect netdata/static-builder --format '{{.Os}}/{{.Architecture}}/{{.Variant}}')"
+ if [ "${img_platform%'/'}" != "${platform}" ]; then
+ docker image rm "${DOCKER_IMAGE_NAME}" || exit 1
+ fi
+fi
- # save the changes made permanently
- id=$(docker ps -l -q)
- run docker commit "${id}" "${DOCKER_CONTAINER_NAME}"
+if ! docker inspect "${DOCKER_IMAGE_NAME}" > /dev/null 2>&1; then
+ docker pull --platform "${platform}" "${DOCKER_IMAGE_NAME}"
fi
# Run the build script inside the container
if [ -t 1 ]; then
- run docker run -e BUILDARCH="${BUILDARCH}" -a stdin -a stdout -a stderr -i -t -v "$(pwd)":/netdata:rw \
- "${DOCKER_CONTAINER_NAME}" \
+ run docker run --rm -e BUILDARCH="${BUILDARCH}" -a stdin -a stdout -a stderr -i -t -v "$(pwd)":/netdata:rw \
+ "${DOCKER_IMAGE_NAME}" \
/bin/sh /netdata/packaging/makeself/build.sh "${@}"
else
- run docker run -e BUILDARCH="${BUILDARCH}" -v "$(pwd)":/netdata:rw \
- -e GITHUB_ACTIONS="${GITHUB_ACTIONS}" "${DOCKER_CONTAINER_NAME}" \
+ run docker run --rm -e BUILDARCH="${BUILDARCH}" -v "$(pwd)":/netdata:rw \
+ -e GITHUB_ACTIONS="${GITHUB_ACTIONS}" "${DOCKER_IMAGE_NAME}" \
/bin/sh /netdata/packaging/makeself/build.sh "${@}"
fi