Fix issue of missing db base build process in build base workflow

There is extra build step for db base image building since v2.3, so this
step should be added back.

Signed-off-by: danfengliu <danfengl@vmware.com>
This commit is contained in:
danfengliu 2021-06-16 15:18:40 +08:00
parent 72f1afe2cc
commit f367aad760
4 changed files with 42 additions and 37 deletions

View File

@ -256,6 +256,8 @@ DOCKERIMGFILE=harbor
HARBORPKG=harbor
# pull/push image
PUSHSCRIPTPATH=$(MAKEPATH)
PUSHSCRIPTNAME=pushimage.sh
REGISTRYUSER=
REGISTRYPASSWORD=
@ -435,10 +437,30 @@ build:
-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) \
-e PUSHBASEIMAGE=$(PUSHBASEIMAGE)
-e PUSHBASEIMAGE=$(PUSHBASEIMAGE) -e BUILD_PG96=$(BUILD_PG96)
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 $(BUILDBASETARGET); do \
echo $$name ; \
sleep 30 ; \
if [ $$name == "db" ]; then \
make _build_base_db ; \
else \
$(DOCKERBUILD) --build-arg BUILD_PG96=$(BUILD_PG96) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/$$name/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . ; \
fi ; \
if [ "$(PUSHBASEIMAGE)" != "false" ] ; then \
$(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) || exit 1; \
fi ; \
done
_build_base_db:
@if [ "$(BUILD_PG96)" = "true" ] ; then \
echo "build pg96 rpm package." ; \

View File

@ -1 +1 @@
v2.3.0
v2.3.0

View File

@ -276,15 +276,23 @@ define _build_base
else \
echo "No docker credentials provided, please be aware of priviledges to access docker hub!" ; \
fi ;\
$(DOCKERBUILD) -f $(2)/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$(1)-base:$(BASEIMAGETAG) --label base-build-date=$(TIMESTAMP) . ;\
if [ "$(1)" = "db" ] && [ "$(BUILD_PG96)" = "true" ]; then \
echo "build pg96 rpm package." ; \
cd $(DOCKERFILEPATH)/db && $(DOCKERFILEPATH)/db/rpm_builder.sh && cd - ; \
$(DOCKERBUILD) --pull --no-cache -f $(DOCKERFILEPATH)/db/Dockerfile.pg96 -t $(BASEIMAGENAMESPACE)/harbor-db-base:$(BASEIMAGETAG) --label base-build-date=$(TIMESTAMP) . ; \
else \
$(DOCKERBUILD) -f $(2)/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$(1)-base:$(BASEIMAGETAG) --label base-build-date=$(TIMESTAMP) . ;\
fi ;\
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)

View File

@ -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,21 +101,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"
@ -128,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
@ -153,3 +127,4 @@ if [ "$PULL_BASE_FROM_DOCKERHUB" == "true" ];then
success "Clean local goharbor images succeeded";
fi
fi