Merge pull request #3129 from LinuxSuRen/fix-docker-login-issues

Avoid docker login everytime even it is done before
This commit is contained in:
KubeSphere CI Bot
2020-11-26 19:35:37 +08:00
committed by GitHub
3 changed files with 15 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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