From eb503f405121ab5f7e2ba63083f991adb4d7d827 Mon Sep 17 00:00:00 2001 From: rick Date: Wed, 18 Nov 2020 22:35:08 +0800 Subject: [PATCH 1/2] Avoid docker login everytime even it is done before Signed-off-by: rick --- hack/docker_build.sh | 10 +++++++++- install/scripts/docker_push | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hack/docker_build.sh b/hack/docker_build.sh index 42c483f78..1bc1114f0 100755 --- a/hack/docker_build.sh +++ b/hack/docker_build.sh @@ -5,6 +5,11 @@ set -o pipefail tag_for_branch() { local tag=$1 + if [[ "${tag}" == "" ]]; then + tag=$(git branch --show-current) + tag=${tag/\//-} + fi + if [[ "${tag}" == "master" ]]; then tag="latest" fi @@ -19,6 +24,9 @@ docker build -f build/ks-apiserver/Dockerfile -t $REPO/ks-apiserver:$TAG . docker build -f build/ks-controller-manager/Dockerfile -t $REPO/ks-controller-manager:$TAG . # Push image to dockerhub, need to support multiple push -echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin +cat ~/.docker/config.json | grep index.docker.io +if [[ $? != 0 ]]; then + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin +fi docker push $REPO/ks-apiserver:$TAG docker push $REPO/ks-controller-manager:$TAG diff --git a/install/scripts/docker_push b/install/scripts/docker_push index 5ab4a6a7c..a15f2f8b1 100644 --- a/install/scripts/docker_push +++ b/install/scripts/docker_push @@ -1,4 +1,7 @@ #!/bin/bash -echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin +cat ~/.docker/config.json | grep index.docker.io +if [[ $? != 0 ]]; then + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin +fi docker push kubespheredev/ks-apiserver:latest From 9a9b768aca9f8cdbfa1fc93d507d8708a8570dbf Mon Sep 17 00:00:00 2001 From: rick Date: Thu, 19 Nov 2020 15:37:39 +0800 Subject: [PATCH 2/2] Add a command to builder docker image without test Signed-off-by: rick --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index f13baf76e..fe40dd0b4 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,8 @@ openapi: # Build the docker image docker-build: all hack/docker_build.sh +docker-build-no-test: ks-apiserver controller-manager + hack/docker_build.sh # Run tests test: fmt vet