From 79d13797d478f3af534167ca27d0a95083174b5e Mon Sep 17 00:00:00 2001 From: Kuniwak Date: Thu, 25 Apr 2024 09:30:06 +0900 Subject: [PATCH] Fix errors of ./scripts/push-image --- scripts/deploy | 6 +-- scripts/{build-image => deploy-images} | 57 ++++++++++++++++++++---- scripts/push-image | 61 -------------------------- 3 files changed, 51 insertions(+), 73 deletions(-) rename scripts/{build-image => deploy-images} (55%) delete mode 100755 scripts/push-image diff --git a/scripts/deploy b/scripts/deploy index 7ea4b50..af5b872 100755 --- a/scripts/deploy +++ b/scripts/deploy @@ -67,11 +67,9 @@ main() { ./scripts/deploy-bins if [[ "$arg" == "--latest" ]]; then - ./scripts/build-image --latest - ./scripts/push-image --latest + ./scripts/deploy-images --latest else - ./scripts/build-image - ./scripts/push-image + ./scripts/deploy-images fi ) } diff --git a/scripts/build-image b/scripts/deploy-images similarity index 55% rename from scripts/build-image rename to scripts/deploy-images index 5394be0..f8a6a80 100755 --- a/scripts/build-image +++ b/scripts/deploy-images @@ -10,7 +10,7 @@ CIRCLECI_DOCKERFILE="${BASE_DIR}/.circleci/images/Dockerfile" usage() { cat - 1>&2 <<-EOS -usage: build-image [] +usage: deploy-images [] OPTIONS -h, --help print this usage @@ -48,21 +48,62 @@ main() { fi # NOTE: --push is necessary, because --load is not supported for multi-platform build yet. - docker buildx build --builder unity-meta-check-driver --platform linux/arm64,linux/amd64 -t "$builder_image:latest" -f "$BUILDER_DOCKERFILE" . --push + docker buildx build \ + --builder unity-meta-check-driver \ + --platform linux/arm64,linux/amd64 \ + --push \ + -t "$builder_image:latest" \ + -f "$BUILDER_DOCKERFILE" . - docker buildx build --builder unity-meta-check-driver --platform linux/arm64,linux/amd64 -t "$image:$version" -f "$DOCKERFILE" . if [[ "$arg" == "--latest" ]]; then - docker tag "$image:$version" "$image:latest" + docker buildx build \ + --builder unity-meta-check-driver \ + --platform linux/arm64,linux/amd64 \ + --push \ + -t "$image:$version" \ + -t "$image:latest" \ + -f "$DOCKERFILE" . + else + docker buildx build \ + --builder unity-meta-check-driver \ + --platform linux/arm64,linux/amd64 \ + --push \ + -t "$image:$version" \ + -f "$DOCKERFILE" . fi - docker buildx build --builder unity-meta-check-driver --platform linux/arm64,linux/amd64 -t "$gh_action_image:$version" -f "$GH_ACTION_DOCKERFILE" . if [[ "$arg" == "--latest" ]]; then - docker tag "$gh_action_image:$version" "$gh_action_image:latest" + docker buildx build \ + --builder unity-meta-check-driver \ + --platform linux/arm64,linux/amd64 \ + --push \ + -t "$gh_action_image:$version" \ + -t "$gh_action_image:latest" \ + -f "$GH_ACTION_DOCKERFILE" . + else + docker buildx build \ + --builder unity-meta-check-driver \ + --platform linux/arm64,linux/amd64 \ + --push \ + -t "$gh_action_image:$version" \ + -f "$GH_ACTION_DOCKERFILE" . fi - docker buildx build --builder unity-meta-check-driver --platform linux/arm64,linux/amd64 -t "$circleci_image:$version" -f "$CIRCLECI_DOCKERFILE" . if [[ "$arg" == "--latest" ]]; then - docker tag "$circleci_image:$version" "$circleci_image:latest" + docker buildx build \ + --builder unity-meta-check-driver \ + --platform linux/arm64,linux/amd64 \ + --push \ + -t "$circleci_image:$version" \ + -t "$circleci_image:latest" \ + -f "$CIRCLECI_DOCKERFILE" . + else + docker buildx build \ + --builder unity-meta-check-driver \ + --platform linux/arm64,linux/amd64 \ + --push \ + -t "$circleci_image:$version" \ + -f "$CIRCLECI_DOCKERFILE" . fi ) } diff --git a/scripts/push-image b/scripts/push-image deleted file mode 100755 index 4e3d418..0000000 --- a/scripts/push-image +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -set -euo pipefail - -BASE_DIR="$(cd "$(dirname "$0")/.."; pwd)" -DOCKERFILE="${BASE_DIR}/Dockerfile" -GH_ACTION_DOCKERFILE="${BASE_DIR}/.github/images/Dockerfile" -CIRCLECI_DOCKERFILE="${BASE_DIR}/.circleci/images/Dockerfile" - - -usage() { - cat - 1>&2 <<-EOS -usage: push-image [] - -OPTIONS - -h, --help print this usage - --latest also push latest -EOS -} - - -main() { - local arg="${1:-}" - - (cd "$BASE_DIR" - local version - version="$("$BASE_DIR/scripts/print-version")" - - local circleci_image - circleci_image="$("$BASE_DIR/scripts/print-image-name" < "$CIRCLECI_DOCKERFILE")" - - local gh_action_image - gh_action_image="$("$BASE_DIR/scripts/print-image-name" < "$GH_ACTION_DOCKERFILE")" - - local image - image="$("$BASE_DIR/scripts/print-image-name" < "$DOCKERFILE")" - - docker push "$image:$version" - if [[ "$arg" == "--latest" ]]; then - docker push "$image:latest" - fi - - docker push "$gh_action_image:$version" - if [[ "$arg" == "--latest" ]]; then - docker push "$gh_action_image:latest" - fi - - docker push "$circleci_image:$version" - if [[ "$arg" == "--latest" ]]; then - docker push "$circleci_image:latest" - fi - ) -} - - -case "$*" in - --help | -h) - usage - false ;; - *) - main "$@" ;; -esac