]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
ci/images: automate build&push of images
authorTomas Krizek <tomas.krizek@nic.cz>
Tue, 21 Dec 2021 16:20:46 +0000 (17:20 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Thu, 13 Jan 2022 11:51:35 +0000 (12:51 +0100)
ci/README.md [deleted file]
ci/images/build.sh [new file with mode: 0755]
ci/images/debian-11/Dockerfile [moved from ci/debian-11/Dockerfile with 100% similarity]
ci/images/debian-buster/Dockerfile [moved from ci/debian-buster/Dockerfile with 100% similarity]
ci/images/push.sh [new file with mode: 0755]
ci/images/update.sh [new file with mode: 0755]
ci/images/vars.sh [new file with mode: 0755]

diff --git a/ci/README.md b/ci/README.md
deleted file mode 100644 (file)
index 8bd70a2..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-Docker Build
-------------
-
-```
-$ export DISTRO=debian-buster # also debian-11
-$ export KNOT_BRANCH=3.0 # also master
-$ docker build --no-cache -t registry.nic.cz/knot/knot-resolver/ci/$DISTRO:knot-$KNOT_BRANCH --build-arg KNOT_BRANCH=$KNOT_BRANCH $DISTRO
-
-$ docker login registry.nic.cz
-$ docker push registry.nic.cz/knot/knot-resolver/ci/$DISTRO:knot-$KNOT_BRANCH
-```
diff --git a/ci/images/build.sh b/ci/images/build.sh
new file mode 100755 (executable)
index 0000000..98a9215
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+# build specified docker image
+
+CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
+source "${CURRENT_DIR}"/vars.sh "$@"
+set -ex
+
+docker build --no-cache -t "${FULL_NAME}" "${IMAGE}" --build-arg KNOT_BRANCH=${KNOT_BRANCH}
diff --git a/ci/images/push.sh b/ci/images/push.sh
new file mode 100755 (executable)
index 0000000..75f5f87
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+# upload docker image into registry
+
+CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
+source "${CURRENT_DIR}"/vars.sh "$@"
+set -ex
+
+docker push "${FULL_NAME}"
diff --git a/ci/images/update.sh b/ci/images/update.sh
new file mode 100755 (executable)
index 0000000..7be5172
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+# build and upload docker image(s) into registry
+#
+# this is a simple wrapper around build.sh and update.sh
+#
+# to build & upload all images: ./update.sh */
+
+if [[ $# -le 0 ]]; then
+    echo "usage: $0 IMAGE..."
+    exit 1
+fi
+set -e
+
+for ARG in "$@"
+do
+    IMAGE=${ARG%/}
+    echo "Building $IMAGE..."
+    ./build.sh $IMAGE
+    echo "Pushing $IMAGE..."
+    ./push.sh $IMAGE
+done
+
diff --git a/ci/images/vars.sh b/ci/images/vars.sh
new file mode 100755 (executable)
index 0000000..f2ea465
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+# define common variables for image build scripts
+
+KNOT_BRANCH="${KNOT_BRANCH:-3.1}"
+
+REGISTRY="registry.nic.cz/knot/knot-resolver/ci"
+IMAGE=$1
+if [ -z "${IMAGE}" ]; then
+    echo "image name not provided"
+    exit 1
+fi
+TAG="knot-${KNOT_BRANCH}"
+FULL_NAME="${REGISTRY}/${IMAGE}:${TAG}"