diff --git a/Makefile b/Makefile index 19de0b46e..40d08b568 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,7 @@ COMPILETAG=compile_normal REGISTRYSERVER= REGISTRYPROJECTNAME=vmware DEVFLAG=true -NORTARYFLAG=false +NOTARYFLAG=false #clarity parameters CLARITYIMAGE=danieljt/harbor-clarity-base[:tag] @@ -209,7 +209,7 @@ compile_clarity: @$(DOCKERCMD) run --rm -v $(UIPATH)/static/new-ui:$(CLARITYSEEDPATH)/dist -v $(UINGPATH)/src:$(CLARITYSEEDPATH)/src -v $(UINGPATH)/src/app:$(CLARITYSEEDPATH)/src/app $(CLARITYIMAGE) $(SHELL) $(CLARITYBUILDSCRIPT) @echo "Done." -compile_normal: compile_clarity, compile_adminserver compile_ui compile_jobservice +compile_normal: compile_clarity compile_adminserver compile_ui compile_jobservice compile_golangimage: compile_clarity @echo "compiling binary for adminserver (golang image)..." @@ -264,18 +264,24 @@ package_online: modify_composefile fi @cp LICENSE $(HARBORPKG)/LICENSE @cp NOTICE $(HARBORPKG)/NOTICE - @$(TARCMD) -zcvf harbor-online-installer-$(VERSIONTAG).tgz \ - --exclude=$(HARBORPKG)/common/db --exclude=$(HARBORPKG)/common/config\ - --exclude=$(HARBORPKG)/photon --exclude=$(HARBORPKG)/kubernetes \ - --exclude=$(HARBORPKG)/dev --exclude=$(DOCKERCOMPOSETPLFILENAME) \ - --exclude=$(HARBORPKG)/checkenv.sh \ - --exclude=$(HARBORPKG)/jsminify.sh \ - --exclude=$(HARBORPKG)/pushimage.sh \ - $(HARBORPKG) - + + @if [ "$(NOTARYFLAG)" = "true" ] ; then \ + $(TARCMD) -zcvf harbor-online-installer-$(VERSIONTAG).tgz \ + $(HARBORPKG)/common/templates $(HARBORPKG)/prepare \ + $(HARBORPKG)/LICENSE $(HARBORPKG)/NOTICE \ + $(HARBORPKG)/install.sh $(HARBORPKG)/$(DOCKERCOMPOSEFILENAME) \ + $(HARBORPKG)/harbor.cfg $(HARBORPKG)/$(DOCKERCOMPOSENOTARYFILENAME); \ + else \ + $(TARCMD) -zcvf harbor-online-installer-$(VERSIONTAG).tgz \ + $(HARBORPKG)/common/templates $(HARBORPKG)/prepare \ + $(HARBORPKG)/LICENSE $(HARBORPKG)/NOTICE \ + $(HARBORPKG)/install.sh $(HARBORPKG)/$(DOCKERCOMPOSEFILENAME) \ + $(HARBORPKG)/harbor.cfg ; \ + fi + @rm -rf $(HARBORPKG) @echo "Done." - + package_offline: compile build modify_composefile @echo "packing offline package ..." @cp -r make $(HARBORPKG) @@ -313,6 +319,21 @@ package_offline: compile build modify_composefile nginx:1.11.5 registry:2.5.1 photon:1.0 ; \ fi + @if [ "$(NOTARYFLAG)" = "true" ] ; then \ + $(TARCMD) -zcvf harbor-offline-installer-$(VERSIONTAG).tgz \ + $(HARBORPKG)/common/templates $(HARBORPKG)/$(DOCKERIMGFILE).$(VERSIONTAG).tgz \ + $(HARBORPKG)/prepare $(HARBORPKG)/NOTICE \ + $(HARBORPKG)/LICENSE $(HARBORPKG)/install.sh \ + $(HARBORPKG)/harbor.cfg $(HARBORPKG)/$(DOCKERCOMPOSEFILENAME) ; \ + else \ + $(TARCMD) -zcvf harbor-offline-installer-$(VERSIONTAG).tgz \ + $(HARBORPKG)/common/templates $(HARBORPKG)/$(DOCKERIMGFILE).$(VERSIONTAG).tgz \ + $(HARBORPKG)/prepare $(HARBORPKG)/NOTICE \ + $(HARBORPKG)/LICENSE $(HARBORPKG)/install.sh \ + $(HARBORPKG)/harbor.cfg $(HARBORPKG)/$(DOCKERCOMPOSEFILENAME) \ + $(HARBORPKG)/$(DOCKERCOMPOSENOTARYFILENAME) ; \ + fi + @rm -rf $(HARBORPKG) @echo "Done." @@ -353,6 +374,11 @@ start: @echo "Start complete. You can visit harbor now." down: + @echo "Please make sure to set -e NOTARYFLAG=true if you are using Notary in Harbor, otherwise the Notary containers cannot be stop automaticlly." + @while [ -z "$$CONTINUE" ]; do \ + read -r -p "Type anything but Y or y to exit. [Y/N]: " CONTINUE; \ + done ; \ + [ $$CONTINUE = "y" ] || [ $$CONTINUE = "Y" ] || (echo "Exiting."; exit 1;) @echo "stoping harbor instance..." @if [ "$(NOTARYFLAG)" = "true" ] ; then \ $(DOCKERCOMPOSECMD) -f $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSEFILENAME) -f $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSENOTARYFILENAME) down ; \ diff --git a/make/install.sh b/make/install.sh index f4f7592a3..54c2b10be 100755 --- a/make/install.sh +++ b/make/install.sh @@ -49,14 +49,20 @@ note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" set -e set +o noglob -usage=$'Please set hostname and other necessary attributes in harbor.cfg first. DO NOT use localhost or 127.0.0.1 for hostname, because Harbor needs to be accessed by external clients.' +usage=$'Please set hostname and other necessary attributes in harbor.cfg first. DO NOT use localhost or 127.0.0.1 for hostname, because Harbor needs to be accessed by external clients. +Please set --with-notary if needs enable Notary in Harbor, and set ui_url_protocol/ssl_cert/ssl_cert_key in harbor.cfg bacause notary must run under https.' item=0 +# notary is not enabled by default +with_notary=$false + while [ $# -gt 0 ]; do case $1 in --help) note "$usage" exit 0;; + --with-notary) + with_notary=true;; *) note "$usage" exit 1;; @@ -146,19 +152,38 @@ if [ -n "$host" ] then sed "s/^hostname = .*/hostname = $host/g" -i ./harbor.cfg fi -./prepare +if [ $with_notary ] +then + ./prepare --with-notary +else + ./prepare +fi echo "" h2 "[Step $item]: checking existing instance of Harbor ..."; let item+=1 -if [ -n "$(docker-compose -f docker-compose*.yml ps -q)" ] -then - note "stopping existing Harbor instance ..." - docker-compose -f docker-compose*.yml down +if [ $with_notary ] +then + if [ -n "$(docker-compose -f docker-compose.yml -f docker-compose.notary.yml ps -q)" ] + then + note "stopping existing Harbor instance ..." + docker-compose -f docker-compose.yml -f docker-compose.notary.yml down + fi +else + if [ -n "$(docker-compose -f docker-compose.yml ps -q)" ] + then + note "stopping existing Harbor instance ..." + docker-compose -f docker-compose.yml down + fi fi echo "" h2 "[Step $item]: starting Harbor ..." -docker-compose -f docker-compose*.yml up -d +if [ $with_notary ] +then + docker-compose -f docker-compose.yml -f docker-compose.notary.yml up -d +else + docker-compose -f docker-compose.yml up -d +fi protocol=http hostname=reg.mydomain.com