From 1eac5a6bd0352ff2366e1feedd01abbd83d59546 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Wed, 26 Jan 2022 09:22:51 +0100 Subject: [PATCH 1/4] Script to push docker image for releases --- maintainers/push-docker.sh | 69 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 maintainers/push-docker.sh diff --git a/maintainers/push-docker.sh b/maintainers/push-docker.sh new file mode 100755 index 000000000..a705f0738 --- /dev/null +++ b/maintainers/push-docker.sh @@ -0,0 +1,69 @@ +#/usr/bin/env bash + +# TODO: parse from .version +MAINTENANCE_VERSION="2.6" +VERSION="$MAINTENANCE_VERSION.0" + +# Should be override `latest` tag, default true +PUSH_AS_LATEST=1 + +PLATFORMS="x86_64-linux aarch64-linux" + +# ensure we are logged to docker hub +docker login + +DOCKER_MANIFEST="" +DOCKER_MANIFEST_LATEST="" + +for PLATFORM in $PLATFORMS; +do + echo "=> Loading docker image for $PLATFORM platform ..." + + DOCKER_IMAGE_TMP_FILE="$PWD/image-$PLATFORM.tar.gz" + if [ ! -f "$DOCKER_IMAGE_TMP_FILE" ]; then + curl -L https://hydra.nixos.org/job/nix/maintenance-$MAINTENANCE_VERSION/dockerImage.$PLATFORM/latest/download/1 > $DOCKER_IMAGE_TMP_FILE + fi + docker load -i $DOCKER_IMAGE_TMP_FILE + + if [ "$PLATFORM" = "x86_64-linux" ]; then DOCKER_PLATFORM="amd64" + elif [ "$PLATFORM" = "aarch64-linux" ]; then DOCKER_PLATFORM="arm64" + else + echo "EROROR: No docker platform found for $PLATFORM platform" + exit 1 + fi + + echo "=> Tagging docker image of version $VERSION for $PLATFORM platform ..." + + docker tag nix:$VERSION nixos/nix:$VERSION-$DOCKER_PLATFORM + if [ $PUSH_AS_LATEST -eq 1 ]; then + echo "=> Tagging docker image of version latest for $PLATFORM platform ..." + docker tag nix:$VERSION nixos/nix:latest + fi + + echo "=> Pushing docker image of version $VERSION for $PLATFORM platform ..." + + docker push nixos/nix:$VERSION-$DOCKER_PLATFORM + if [ $PUSH_AS_LATEST -eq 1 ]; then + echo "=> Pushing docker image of version latest for $PLATFORM platform ..." + docker push nixos/nix:latest + fi + + DOCKER_MANIFEST="$DOCKER_MANIFEST --amend nixos/nix:$VERSION-$DOCKER_PLATFORM" + DOCKER_MANIFEST_LATEST="$DOCKER_MANIFEST_LATEST --amend nixos/nix:latest-$DOCKER_PLATFORM" + + echo +done + +echo "=> Creating $VERSION multi platform docker manifest for the following platforms: $PLATFORMS ..." +docker manifest create nixos/nix:$VERSION $DOCKER_MANIFEST +if [ $PUSH_AS_LATEST -eq 1 ]; then + echo "=> Creating latest multi platform docker manifest for the following platforms: $PLATFORMS ..." + docker manifest create nixos/nix:latest $DOCKER_MANIFEST_LATEST +fi + +echo "=> Pushing $VERSION multi platform docker manifest ..." +docker manifest push nixos/nix:$VERSION +if [ $PUSH_AS_LATEST -eq 1 ]; then + echo "=> Pushing latest multi platform docker manifest ..." + docker manifest push nixos/nix:latest +fi From 4fc3c4da7ba81a69c17063950933b45b39646949 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Wed, 26 Jan 2022 10:01:58 +0100 Subject: [PATCH 2/4] typo --- maintainers/push-docker.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maintainers/push-docker.sh b/maintainers/push-docker.sh index a705f0738..fe8fe174e 100755 --- a/maintainers/push-docker.sh +++ b/maintainers/push-docker.sh @@ -37,7 +37,7 @@ do docker tag nix:$VERSION nixos/nix:$VERSION-$DOCKER_PLATFORM if [ $PUSH_AS_LATEST -eq 1 ]; then echo "=> Tagging docker image of version latest for $PLATFORM platform ..." - docker tag nix:$VERSION nixos/nix:latest + docker tag nix:$VERSION nixos/nix:latest-$DOCKER_PLATFORM fi echo "=> Pushing docker image of version $VERSION for $PLATFORM platform ..." @@ -45,7 +45,7 @@ do docker push nixos/nix:$VERSION-$DOCKER_PLATFORM if [ $PUSH_AS_LATEST -eq 1 ]; then echo "=> Pushing docker image of version latest for $PLATFORM platform ..." - docker push nixos/nix:latest + docker push nixos/nix:latest-$DOCKER_PLATFORM fi DOCKER_MANIFEST="$DOCKER_MANIFEST --amend nixos/nix:$VERSION-$DOCKER_PLATFORM" From 50a9c48db4dddd6ba4c81dae74aa60f8ff10bfe5 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Wed, 26 Jan 2022 10:05:33 +0100 Subject: [PATCH 3/4] fail early --- maintainers/push-docker.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/maintainers/push-docker.sh b/maintainers/push-docker.sh index fe8fe174e..f9c5a6b18 100755 --- a/maintainers/push-docker.sh +++ b/maintainers/push-docker.sh @@ -17,6 +17,13 @@ DOCKER_MANIFEST_LATEST="" for PLATFORM in $PLATFORMS; do + if [ "$PLATFORM" = "x86_64-linux" ]; then DOCKER_PLATFORM="amd64" + elif [ "$PLATFORM" = "aarch64-linux" ]; then DOCKER_PLATFORM="arm64" + else + echo "EROROR: No docker platform found for $PLATFORM platform" + exit 1 + fi + echo "=> Loading docker image for $PLATFORM platform ..." DOCKER_IMAGE_TMP_FILE="$PWD/image-$PLATFORM.tar.gz" @@ -25,13 +32,6 @@ do fi docker load -i $DOCKER_IMAGE_TMP_FILE - if [ "$PLATFORM" = "x86_64-linux" ]; then DOCKER_PLATFORM="amd64" - elif [ "$PLATFORM" = "aarch64-linux" ]; then DOCKER_PLATFORM="arm64" - else - echo "EROROR: No docker platform found for $PLATFORM platform" - exit 1 - fi - echo "=> Tagging docker image of version $VERSION for $PLATFORM platform ..." docker tag nix:$VERSION nixos/nix:$VERSION-$DOCKER_PLATFORM From f0de5fb8e733e45f1d96fdf842eab7cdfc598c60 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Fri, 18 Feb 2022 00:32:38 +0100 Subject: [PATCH 4/4] remove the manifest before creating them --- maintainers/push-docker.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maintainers/push-docker.sh b/maintainers/push-docker.sh index f9c5a6b18..2aa953a78 100755 --- a/maintainers/push-docker.sh +++ b/maintainers/push-docker.sh @@ -2,7 +2,7 @@ # TODO: parse from .version MAINTENANCE_VERSION="2.6" -VERSION="$MAINTENANCE_VERSION.0" +VERSION="$MAINTENANCE_VERSION.1" # Should be override `latest` tag, default true PUSH_AS_LATEST=1 @@ -55,9 +55,11 @@ do done echo "=> Creating $VERSION multi platform docker manifest for the following platforms: $PLATFORMS ..." +docker manifest rm nixos/nix:$VERSION $DOCKER_MANIFEST docker manifest create nixos/nix:$VERSION $DOCKER_MANIFEST if [ $PUSH_AS_LATEST -eq 1 ]; then echo "=> Creating latest multi platform docker manifest for the following platforms: $PLATFORMS ..." + docker manifest rm nixos/nix:latest $DOCKER_MANIFEST_LATEST docker manifest create nixos/nix:latest $DOCKER_MANIFEST_LATEST fi