diff --git a/Makefile b/Makefile index 21670892e..9f6fdb6b5 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ REGISTRY_SRC_TAG=v2.7.1 # dependency binaries CHARTURL=https://storage.googleapis.com/harbor-builds/bin/chartmuseum/release-${CHARTMUSEUMVERSION}/chartm -NORARYURL=https://storage.googleapis.com/harbor-builds/bin/notary/release-${NOTARYVERSION}/binary-bundle.tgz +NOTARYURL=https://storage.googleapis.com/harbor-builds/bin/notary/release-${NOTARYVERSION}/binary-bundle.tgz REGISTRYURL=https://storage.googleapis.com/harbor-builds/bin/registry/release-${REGISTRYVERSION}/registry TRIVY_DOWNLOAD_URL=https://github.com/aquasecurity/trivy/releases/download/$(TRIVYVERSION)/trivy_$(TRIVYVERSION:v%=%)_Linux-64bit.tar.gz TRIVY_ADAPTER_DOWNLOAD_URL=https://github.com/aquasecurity/harbor-scanner-trivy/releases/download/$(TRIVYADAPTERVERSION)/harbor-scanner-trivy_$(TRIVYADAPTERVERSION:v%=%)_Linux_x86_64.tar.gz @@ -415,7 +415,7 @@ build: -e BUILDBIN=$(BUILDBIN) \ -e CHARTMUSEUMVERSION=$(CHARTMUSEUMVERSION) -e CHARTMUSEUM_SRC_TAG=$(CHARTMUSEUM_SRC_TAG) -e DOCKERIMAGENAME_CHART_SERVER=$(DOCKERIMAGENAME_CHART_SERVER) \ -e NPM_REGISTRY=$(NPM_REGISTRY) -e BASEIMAGETAG=$(BASEIMAGETAG) -e BASEIMAGENAMESPACE=$(BASEIMAGENAMESPACE) \ - -e CHARTURL=$(CHARTURL) -e NORARYURL=$(NORARYURL) -e REGISTRYURL=$(REGISTRYURL) \ + -e CHARTURL=$(CHARTURL) -e NOTARYURL=$(NOTARYURL) -e REGISTRYURL=$(REGISTRYURL) \ -e TRIVY_DOWNLOAD_URL=$(TRIVY_DOWNLOAD_URL) -e TRIVY_ADAPTER_DOWNLOAD_URL=$(TRIVY_ADAPTER_DOWNLOAD_URL) \ -e PULL_BASE_FROM_DOCKERHUB=$(PULL_BASE_FROM_DOCKERHUB) -e BUILD_BASE=$(BUILD_BASE) \ -e REGISTRYUSER=$(REGISTRYUSER) -e REGISTRYPASSWORD=$(REGISTRYPASSWORD) \ @@ -423,6 +423,20 @@ build: 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 privileges to access docker hub!" ; \ + fi + @for name in $(BUILDBASETARGET); 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 [ "$(PUSHBASEIMAGE)" != "false" ] ; then \ + $(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) || exit 1; \ + fi ; \ + done pull_base_docker: @for name in $(BUILDBASETARGET); do \ diff --git a/VERSION b/VERSION index 0b1f88b80..93de778c2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.2.3 +v2.2.3 \ No newline at end of file diff --git a/make/photon/Makefile b/make/photon/Makefile index ffe1c705a..a23faaa40 100644 --- a/make/photon/Makefile +++ b/make/photon/Makefile @@ -210,7 +210,7 @@ _build_notary: $(call _build_base,$(NOTARYSIGNER),$(DOCKERFILEPATH_NOTARYSIGNER)) ; \ if [ "$(BUILDBIN)" != "true" ] ; then \ rm -rf $(DOCKERFILEPATH_NOTARY)/binary && mkdir -p $(DOCKERFILEPATH_NOTARY)/binary && \ - $(call _get_binary, $(NORARYURL), $(DOCKERFILEPATH_NOTARY)/binary-bundle.tgz); \ + $(call _get_binary, $(NOTARYURL), $(DOCKERFILEPATH_NOTARY)/binary-bundle.tgz); \ cd $(DOCKERFILEPATH_NOTARY) && tar -zvxf binary-bundle.tgz && cd - ; \ else \ cd $(DOCKERFILEPATH_NOTARY) && $(DOCKERFILEPATH_NOTARY)/builder $(NOTARYVERSION) $(NOTARYMIGRATEVERSION) && cd - ; \ @@ -278,13 +278,15 @@ define _build_base fi ;\ $(DOCKERBUILD) -f $(2)/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$(1)-base:$(BASEIMAGETAG) --label base-build-date=$(TIMESTAMP) . ;\ if [ "$(PUSHBASEIMAGE)" = "true" ] ; then \ - $(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(BASEIMAGENAMESPACE)/harbor-$(1)-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) $(PULL_BASE_FROM_DOCKERHUB) || exit 1; \ + $(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(BASEIMAGENAMESPACE)/harbor-$(1)-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) docker.io $(PULL_BASE_FROM_DOCKERHUB) || exit 1; \ fi ; \ fi endef build: _build_prepare _build_db _build_portal _build_core _build_jobservice _build_log _build_nginx _build_registry _build_registryctl _build_notary _build_trivy_adapter _build_redis _build_chart_server _compile_and_build_exporter - + @if [ -n "$(REGISTRYUSER)" ] && [ -n "$(REGISTRYPASSWORD)" ] ; then \ + docker logout ; \ + fi cleanimage: @echo "cleaning image for photon..." - $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_PORTAL):$(VERSIONTAG) diff --git a/make/pushimage.sh b/make/pushimage.sh index a87b9e690..8841830e4 100755 --- a/make/pushimage.sh +++ b/make/pushimage.sh @@ -4,9 +4,9 @@ set +e set -o noglob if [ "$1" == "" ];then -echo "This shell will push specific image to registry server." -echo "Usage: #./pushimage [image tag] [registry username] [registry password] [registry server]" -exit 1 + echo "This shell will push specific image to registry server." + echo "Usage: #./pushimage [image tag] [registry username] [registry password] [registry server]" + exit 1 fi # @@ -90,7 +90,9 @@ USERNAME="$2" PASSWORD="$3" REGISTRY="$4" PULL_BASE_FROM_DOCKERHUB="$5" + set -e +set -x # ----- Pushing image(s) ----- # see documentation : @@ -99,19 +101,6 @@ set -e # - https://docs.docker.com/reference/commandline/cli/#logout # --------------------------- -# Login docker -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" @@ -126,22 +115,9 @@ 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 - if [ "$PULL_BASE_FROM_DOCKERHUB" == "true" ];then h2 "Remove local goharbor images" - DOCKER_RMI="docker rmi $(docker images | grep "goharbor" | awk '{print $3}') -f" + DOCKER_RMI="docker rmi -f $(docker images | grep "${IMAGE%:*}" | awk '{print $3}') -f" info "$DOCKER_RMI" DOCKER_RMI_OUTPUT=$($DOCKER_RMI) if [ $? -ne 0 ];then