Skip to content

Commit 74ecf35

Browse files
authored
Merge pull request #15258 from danfengliu/fix-build-base-issue-2.2.0
cherry-pick fixing for build base issue
2 parents c6dbbf3 + dc830aa commit 74ecf35

File tree

4 files changed

+28
-36
lines changed

4 files changed

+28
-36
lines changed

Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ REGISTRY_SRC_TAG=v2.7.1
122122

123123
# dependency binaries
124124
CHARTURL=https://storage.googleapis.com/harbor-builds/bin/chartmuseum/release-${CHARTMUSEUMVERSION}/chartm
125-
NORARYURL=https://storage.googleapis.com/harbor-builds/bin/notary/release-${NOTARYVERSION}/binary-bundle.tgz
125+
NOTARYURL=https://storage.googleapis.com/harbor-builds/bin/notary/release-${NOTARYVERSION}/binary-bundle.tgz
126126
REGISTRYURL=https://storage.googleapis.com/harbor-builds/bin/registry/release-${REGISTRYVERSION}/registry
127127
TRIVY_DOWNLOAD_URL=https://github.com/aquasecurity/trivy/releases/download/$(TRIVYVERSION)/trivy_$(TRIVYVERSION:v%=%)_Linux-64bit.tar.gz
128128
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,14 +415,28 @@ build:
415415
-e BUILDBIN=$(BUILDBIN) \
416416
-e CHARTMUSEUMVERSION=$(CHARTMUSEUMVERSION) -e CHARTMUSEUM_SRC_TAG=$(CHARTMUSEUM_SRC_TAG) -e DOCKERIMAGENAME_CHART_SERVER=$(DOCKERIMAGENAME_CHART_SERVER) \
417417
-e NPM_REGISTRY=$(NPM_REGISTRY) -e BASEIMAGETAG=$(BASEIMAGETAG) -e BASEIMAGENAMESPACE=$(BASEIMAGENAMESPACE) \
418-
-e CHARTURL=$(CHARTURL) -e NORARYURL=$(NORARYURL) -e REGISTRYURL=$(REGISTRYURL) \
418+
-e CHARTURL=$(CHARTURL) -e NOTARYURL=$(NOTARYURL) -e REGISTRYURL=$(REGISTRYURL) \
419419
-e TRIVY_DOWNLOAD_URL=$(TRIVY_DOWNLOAD_URL) -e TRIVY_ADAPTER_DOWNLOAD_URL=$(TRIVY_ADAPTER_DOWNLOAD_URL) \
420420
-e PULL_BASE_FROM_DOCKERHUB=$(PULL_BASE_FROM_DOCKERHUB) -e BUILD_BASE=$(BUILD_BASE) \
421421
-e REGISTRYUSER=$(REGISTRYUSER) -e REGISTRYPASSWORD=$(REGISTRYPASSWORD) \
422422
-e PUSHBASEIMAGE=$(PUSHBASEIMAGE)
423423

424424
build_standalone_db_migrator: compile_standalone_db_migrator
425425
make -f $(MAKEFILEPATH_PHOTON)/Makefile _build_standalone_db_migrator -e BASEIMAGETAG=$(BASEIMAGETAG) -e VERSIONTAG=$(VERSIONTAG)
426+
build_base_docker:
427+
if [ -n "$(REGISTRYUSER)" ] && [ -n "$(REGISTRYPASSWORD)" ] ; then \
428+
docker login -u $(REGISTRYUSER) -p $(REGISTRYPASSWORD) ; \
429+
else \
430+
echo "No docker credentials provided, please make sure enough privileges to access docker hub!" ; \
431+
fi
432+
@for name in $(BUILDBASETARGET); do \
433+
echo $$name ; \
434+
sleep 30 ; \
435+
$(DOCKERBUILD) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/$$name/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . && \
436+
if [ "$(PUSHBASEIMAGE)" != "false" ] ; then \
437+
$(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) || exit 1; \
438+
fi ; \
439+
done
426440

427441
pull_base_docker:
428442
@for name in $(BUILDBASETARGET); do \

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.2.3
1+
v2.2.3

make/photon/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ _build_notary:
210210
$(call _build_base,$(NOTARYSIGNER),$(DOCKERFILEPATH_NOTARYSIGNER)) ; \
211211
if [ "$(BUILDBIN)" != "true" ] ; then \
212212
rm -rf $(DOCKERFILEPATH_NOTARY)/binary && mkdir -p $(DOCKERFILEPATH_NOTARY)/binary && \
213-
$(call _get_binary, $(NORARYURL), $(DOCKERFILEPATH_NOTARY)/binary-bundle.tgz); \
213+
$(call _get_binary, $(NOTARYURL), $(DOCKERFILEPATH_NOTARY)/binary-bundle.tgz); \
214214
cd $(DOCKERFILEPATH_NOTARY) && tar -zvxf binary-bundle.tgz && cd - ; \
215215
else \
216216
cd $(DOCKERFILEPATH_NOTARY) && $(DOCKERFILEPATH_NOTARY)/builder $(NOTARYVERSION) $(NOTARYMIGRATEVERSION) && cd - ; \
@@ -278,13 +278,15 @@ define _build_base
278278
fi ;\
279279
$(DOCKERBUILD) -f $(2)/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$(1)-base:$(BASEIMAGETAG) --label base-build-date=$(TIMESTAMP) . ;\
280280
if [ "$(PUSHBASEIMAGE)" = "true" ] ; then \
281-
$(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(BASEIMAGENAMESPACE)/harbor-$(1)-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) $(PULL_BASE_FROM_DOCKERHUB) || exit 1; \
281+
$(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(BASEIMAGENAMESPACE)/harbor-$(1)-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) docker.io $(PULL_BASE_FROM_DOCKERHUB) || exit 1; \
282282
fi ; \
283283
fi
284284
endef
285285

286286
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
287-
287+
@if [ -n "$(REGISTRYUSER)" ] && [ -n "$(REGISTRYPASSWORD)" ] ; then \
288+
docker logout ; \
289+
fi
288290
cleanimage:
289291
@echo "cleaning image for photon..."
290292
- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_PORTAL):$(VERSIONTAG)

make/pushimage.sh

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ set +e
44
set -o noglob
55

66
if [ "$1" == "" ];then
7-
echo "This shell will push specific image to registry server."
8-
echo "Usage: #./pushimage [image tag] [registry username] [registry password] [registry server]"
9-
exit 1
7+
echo "This shell will push specific image to registry server."
8+
echo "Usage: #./pushimage [image tag] [registry username] [registry password] [registry server]"
9+
exit 1
1010
fi
1111

1212
#
@@ -90,7 +90,9 @@ USERNAME="$2"
9090
PASSWORD="$3"
9191
REGISTRY="$4"
9292
PULL_BASE_FROM_DOCKERHUB="$5"
93+
9394
set -e
95+
set -x
9496

9597
# ----- Pushing image(s) -----
9698
# see documentation :
@@ -99,19 +101,6 @@ set -e
99101
# - https://docs.docker.com/reference/commandline/cli/#logout
100102
# ---------------------------
101103

102-
# Login docker
103-
h2 "Login to the Docker registry"
104-
DOCKER_LOGIN="docker login --username $USERNAME --password $PASSWORD $REGISTRY"
105-
info "docker login --username $USERNAME --password *******"
106-
DOCKER_LOGIN_OUTPUT=$($DOCKER_LOGIN)
107-
if [ $? -ne 0 ]; then
108-
warn "$DOCKER_LOGIN_OUTPUT"
109-
error "Login to Docker registry $REGISTRY failed"
110-
exit 1
111-
else
112-
success "Login to Docker registry $REGISTRY succeeded";
113-
fi
114-
115104
# Push the docker image
116105
h2 "Pushing image to Docker registry"
117106

@@ -126,22 +115,9 @@ else
126115
success "Pushing image $IMAGE succeeded";
127116
fi
128117

129-
# Logout from the registry
130-
h2 "Logout from the docker registry"
131-
DOCKER_LOGOUT="docker logout $REGISTRY"
132-
DOCKER_LOGOUT_OUTPUT=$($DOCKER_LOGOUT)
133-
134-
if [ $? -ne 0 ]; then
135-
warn "$DOCKER_LOGOUT_OUTPUT"
136-
error "Logout from Docker registry $REGISTRY failed"
137-
exit 1
138-
else
139-
success "Logout from Docker registry $REGISTRY succeeded"
140-
fi
141-
142118
if [ "$PULL_BASE_FROM_DOCKERHUB" == "true" ];then
143119
h2 "Remove local goharbor images"
144-
DOCKER_RMI="docker rmi $(docker images | grep "goharbor" | awk '{print $3}') -f"
120+
DOCKER_RMI="docker rmi -f $(docker images | grep "${IMAGE%:*}" | awk '{print $3}') -f"
145121
info "$DOCKER_RMI"
146122
DOCKER_RMI_OUTPUT=$($DOCKER_RMI)
147123
if [ $? -ne 0 ];then

0 commit comments

Comments
 (0)