From 481ba06003f31bf44c6263003079f326690aae93 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Thu, 9 Mar 2017 03:02:44 -0800 Subject: [PATCH] support notary --- Makefile | 17 +++++++++++++++- make/install.sh | 53 ++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 9d1bf881b..a17da89a6 100644 --- a/Makefile +++ b/Makefile @@ -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)..." @@ -313,6 +313,16 @@ package_offline: compile build modify_composefile nginx:1.11.5 registry:2.5.1 photon:1.0 ; \ fi + @$(TARCMD) -zcvf harbor-offline-installer-$(VERSIONTAG).tgz \ + --exclude=$(HARBORPKG)/common/db --exclude=$(HARBORPKG)/common/config\ + --exclude=$(HARBORPKG)/common/log --exclude=$(HARBORPKG)/ubuntu \ + --exclude=$(HARBORPKG)/photon --exclude=$(HARBORPKG)/kubernetes \ + --exclude=$(HARBORPKG)/dev --exclude=$(DOCKERCOMPOSETPLFILENAME) \ + --exclude=$(HARBORPKG)/checkenv.sh \ + --exclude=$(HARBORPKG)/jsminify.sh \ + --exclude=$(HARBORPKG)/pushimage.sh \ + $(HARBORPKG) + @rm -rf $(HARBORPKG) @echo "Done." @@ -353,6 +363,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..e10b36a02 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 in harbor.cfg to https 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;; @@ -74,6 +80,20 @@ then exit 1 fi +# The ui_url_protocol in harbor.cfg has not been modified to https in notary mode +if [ $with_notary ] +then + if [[ $(cat ./harbor.cfg) =~ ui_url_protocol[[:blank:]]*=[[:blank:]]*(https?) ]] + then + protocol=${BASH_REMATCH[1]} + if [ "$protocol" != "https" ] + then + warn "$usage" + exit 1 + fi + fi +fi + function check_docker { if ! docker --version &> /dev/null then @@ -146,19 +166,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