Skip to content

Commit

Permalink
Merge pull request #14227 from danfengliu/cherry-pick-2.2.0-reschedul…
Browse files Browse the repository at this point in the history
…e-docker-login-policy-in-build-base-images

[Cherry-pick 2.2.0] Reschedule docker login policy in base image build process
  • Loading branch information
danfengliu authored Feb 24, 2021
2 parents ec0ba11 + a1bbd1a commit a43da2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ HARBORPKG=harbor
# pushimage
PUSHSCRIPTPATH=$(MAKEPATH)
PUSHSCRIPTNAME=pushimage.sh
REGISTRYUSER=user
REGISTRYPASSWORD=default
REGISTRYUSER=
REGISTRYPASSWORD=

# cmds
DOCKERSAVE_PARA=$(DOCKER_IMAGE_NAME_PREPARE):$(VERSIONTAG) \
Expand Down Expand Up @@ -411,8 +411,14 @@ build_standalone_db_migrator: compile_standalone_db_migrator
make -f $(MAKEFILEPATH_PHOTON)/Makefile _build_standalone_db_migrator -e BASEIMAGETAG=$(BASEIMAGETAG) -e VERSIONTAG=$(VERSIONTAG)

build_base_docker:
if [ -n "$(REGISTRYUSER)" ] && [ -n "$(REGISTRYPASSWORD)" ] ; then \
docker login -u $(REGISTRYUSER) -p $(REGISTRYPASSWORD) ; \
else \
echo "No docker credentials provided, please make sure enough priviledges to access docker hub!" ; \
fi
@for name in chartserver trivy-adapter core db jobservice log nginx notary-server notary-signer portal prepare redis registry registryctl; do \
echo $$name ; \
sleep 30 ; \
$(DOCKERBUILD) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/$$name/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . && \
if [ -n "$(PUSHBASEIMAGE)" ] ; then \
$(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) || exit 1; \
Expand Down
28 changes: 0 additions & 28 deletions make/pushimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,6 @@ set -e
# - https://docs.docker.com/reference/commandline/cli/#logout
# ---------------------------

# Login to the registry
h2 "Login to the Docker registry"

DOCKER_LOGIN="docker login --username $USERNAME --password $PASSWORD $REGISTRY"
info "docker login --username $USERNAME --password *******"
DOCKER_LOGIN_OUTPUT=$($DOCKER_LOGIN)

if [ $? -ne 0 ]; then
warn "$DOCKER_LOGIN_OUTPUT"
error "Login to Docker registry $REGISTRY failed"
exit 1
else
success "Login to Docker registry $REGISTRY succeeded";
fi

# Push the docker image
h2 "Pushing image to Docker registry"

Expand All @@ -127,16 +112,3 @@ if [ $? -ne 0 ];then
else
success "Pushing image $IMAGE succeeded";
fi

# Logout from the registry
h2 "Logout from the docker registry"
DOCKER_LOGOUT="docker logout $REGISTRY"
DOCKER_LOGOUT_OUTPUT=$($DOCKER_LOGOUT)

if [ $? -ne 0 ]; then
warn "$DOCKER_LOGOUT_OUTPUT"
error "Logout from Docker registry $REGISTRY failed"
exit 1
else
success "Logout from Docker registry $REGISTRY succeeded"
fi

0 comments on commit a43da2a

Please sign in to comment.