2017-03-23 05:36:36 +01:00
# Makefile for Harbor project
2017-06-13 11:13:24 +02:00
#
2017-03-23 05:36:36 +01:00
# Targets:
#
2017-06-13 11:13:24 +02:00
# all: prepare env, compile binarys, build images and install images
2017-03-23 05:36:36 +01:00
# prepare: prepare env
# compile: compile adminserver, ui and jobservice code
#
# compile_golangimage:
# compile from golang image
# for example: make compile_golangimage -e GOBUILDIMAGE= \
# golang:1.7.3
2018-09-12 08:38:29 +02:00
# compile_adminserver, compile_core, compile_jobservice: compile specific binary
2017-03-23 05:36:36 +01:00
#
2017-12-09 19:53:12 +01:00
# build: build Harbor docker images from photon baseimage
2017-06-13 11:13:24 +02:00
#
# install: include compile binarys, build images, prepare specific \
2017-03-23 05:36:36 +01:00
# version composefile and startup Harbor instance
#
2017-06-13 11:13:24 +02:00
# start: startup Harbor instance
2017-03-23 05:36:36 +01:00
#
# down: shutdown Harbor instance
#
# package_online:
# prepare online install package
# for example: make package_online -e DEVFLAG=false\
2018-09-03 11:40:26 +02:00
# REGISTRYSERVER=reg-bj.goharbor.io \
2017-03-23 05:36:36 +01:00
# REGISTRYPROJECTNAME=harborrelease
2017-06-13 11:13:24 +02:00
#
2017-03-23 05:36:36 +01:00
# package_offline:
# prepare offline install package
2017-06-13 11:13:24 +02:00
#
2017-03-23 05:36:36 +01:00
# pushimage: push Harbor images to specific registry server
# for example: make pushimage -e DEVFLAG=false REGISTRYUSER=admin \
# REGISTRYPASSWORD=***** \
2018-09-03 11:40:26 +02:00
# REGISTRYSERVER=reg-bj.goharbor.io/ \
2017-03-23 05:36:36 +01:00
# REGISTRYPROJECTNAME=harborrelease
# note**: need add "/" on end of REGISTRYSERVER. If not setting \
# this value will push images directly to dockerhub.
2018-09-03 11:40:26 +02:00
# make pushimage -e DEVFLAG=false REGISTRYUSER=goharbor \
2017-03-23 05:36:36 +01:00
# REGISTRYPASSWORD=***** \
2018-09-03 11:40:26 +02:00
# REGISTRYPROJECTNAME=goharbor
2017-03-23 05:36:36 +01:00
#
# clean: remove binary, Harbor images, specific version docker-compose \
# file, specific version tag and online/offline install package
# cleanbinary: remove adminserver, ui and jobservice binary
2017-06-13 11:13:24 +02:00
# cleanimage: remove Harbor images
# cleandockercomposefile:
# remove specific version docker-compose
2017-03-23 05:36:36 +01:00
# cleanversiontag:
# cleanpackageremove specific version tag
# cleanpackage: remove online/offline install package
2017-06-13 11:13:24 +02:00
#
2017-03-23 05:36:36 +01:00
# other example:
# clean specific version binarys and images:
# make clean -e VERSIONTAG=[TAG]
# note**: If commit new code to github, the git commit TAG will \
# change. Better use this commond clean previous images and \
2017-06-13 11:13:24 +02:00
# files with specific TAG.
2017-03-23 05:36:36 +01:00
# By default DEVFLAG=true, if you want to release new version of Harbor, \
# should setting the flag to false.
# make XXXX -e DEVFLAG=false
SHELL := /bin/bash
BUILDPATH = $( CURDIR)
MAKEPATH = $( BUILDPATH) /make
MAKEDEVPATH = $( MAKEPATH) /dev
SRCPATH = ./src
TOOLSPATH = $( BUILDPATH) /tools
2018-09-12 08:38:29 +02:00
CORE_PATH = $( BUILDPATH) /src/core
PORTAL_PATH = $( BUILDPATH) /src/portal
2018-08-23 09:02:20 +02:00
GOBASEPATH = /go/src/github.com/goharbor
2017-03-23 05:36:36 +01:00
CHECKENVCMD = checkenv.sh
2017-12-09 19:53:12 +01:00
# parameters
2017-03-23 05:36:36 +01:00
REGISTRYSERVER =
2018-08-23 09:02:20 +02:00
REGISTRYPROJECTNAME = goharbor
2017-03-23 05:36:36 +01:00
DEVFLAG = true
NOTARYFLAG = false
2017-12-09 19:53:12 +01:00
CLAIRFLAG = false
2017-03-23 05:36:36 +01:00
HTTPPROXY =
2017-12-09 19:53:12 +01:00
BUILDBIN = false
MIGRATORFLAG = false
2018-07-19 10:47:05 +02:00
# enable/disable chart repo supporting
CHARTFLAG = false
2017-03-23 05:36:36 +01:00
2017-12-09 19:53:12 +01:00
# version prepare
2018-03-21 06:03:49 +01:00
# for docker image tag
2018-01-22 09:43:00 +01:00
VERSIONTAG = dev
2018-03-21 06:03:49 +01:00
# for harbor package name
PKGVERSIONTAG = dev
2018-03-23 10:56:29 +01:00
# for harbor about dialog
UIVERSIONTAG = dev
2017-12-09 19:53:12 +01:00
VERSIONFILEPATH = $( CURDIR)
2018-03-21 06:03:49 +01:00
VERSIONFILENAME = UIVERSION
2017-12-09 19:53:12 +01:00
#versions
REGISTRYVERSION = v2.6.2
NGINXVERSION = $( VERSIONTAG)
2018-08-27 09:52:09 +02:00
NOTARYVERSION = v0.6.1
2018-08-31 09:59:56 +02:00
CLAIRVERSION = v2.0.5
2017-12-09 19:53:12 +01:00
CLAIRDBVERSION = $( VERSIONTAG)
2018-07-04 14:03:44 +02:00
MIGRATORVERSION = $( VERSIONTAG)
2018-03-30 07:22:10 +02:00
REDISVERSION = $( VERSIONTAG)
2018-09-08 13:11:44 +02:00
2018-07-19 10:47:05 +02:00
# version of chartmuseum
CHARTMUSEUMVERSION = v0.7.1
2017-06-13 11:13:24 +02:00
2017-03-23 05:36:36 +01:00
# docker parameters
DOCKERCMD = $( shell which docker)
DOCKERBUILD = $( DOCKERCMD) build
DOCKERRMIMAGE = $( DOCKERCMD) rmi
DOCKERPULL = $( DOCKERCMD) pull
DOCKERIMASES = $( DOCKERCMD) images
DOCKERSAVE = $( DOCKERCMD) save
DOCKERCOMPOSECMD = $( shell which docker-compose)
DOCKERTAG = $( DOCKERCMD) tag
# go parameters
GOCMD = $( shell which go)
GOBUILD = $( GOCMD) build
GOCLEAN = $( GOCMD) clean
GOINSTALL = $( GOCMD) install
GOTEST = $( GOCMD) test
GODEP = $( GOTEST) -i
GOFMT = gofmt -w
2018-07-19 10:47:05 +02:00
GOBUILDIMAGE = golang:1.9.2
2017-03-23 05:36:36 +01:00
GOBUILDPATH = $( GOBASEPATH) /harbor
GOIMAGEBUILDCMD = /usr/local/go/bin/go
GOIMAGEBUILD = $( GOIMAGEBUILDCMD) build
GOBUILDPATH_ADMINSERVER = $( GOBUILDPATH) /src/adminserver
2018-09-12 08:38:29 +02:00
GOBUILDPATH_CORE = $( GOBUILDPATH) /src/core
2017-03-23 05:36:36 +01:00
GOBUILDPATH_JOBSERVICE = $( GOBUILDPATH) /src/jobservice
2018-07-16 10:50:28 +02:00
GOBUILDPATH_REGISTRYCTL = $( GOBUILDPATH) /src/registryctl
2017-03-23 05:36:36 +01:00
GOBUILDMAKEPATH = $( GOBUILDPATH) /make
2018-09-03 11:40:26 +02:00
GOBUILDMAKEPATH_ADMINSERVER = $( GOBUILDMAKEPATH) /photon/adminserver
2018-09-12 08:38:29 +02:00
GOBUILDMAKEPATH_CORE = $( GOBUILDMAKEPATH) /photon/core
2018-09-03 11:40:26 +02:00
GOBUILDMAKEPATH_JOBSERVICE = $( GOBUILDMAKEPATH) /photon/jobservice
GOBUILDMAKEPATH_REGISTRYCTL = $( GOBUILDMAKEPATH) /photon/registryctl
2017-03-23 05:36:36 +01:00
2017-06-13 11:13:24 +02:00
# binary
2017-03-23 05:36:36 +01:00
ADMINSERVERBINARYPATH = $( MAKEDEVPATH) /adminserver
ADMINSERVERBINARYNAME = harbor_adminserver
2018-09-12 08:38:29 +02:00
CORE_BINARYPATH = $( MAKEDEVPATH) /core
CORE_BINARYNAME = harbor_core
2017-03-23 05:36:36 +01:00
JOBSERVICEBINARYPATH = $( MAKEDEVPATH) /jobservice
JOBSERVICEBINARYNAME = harbor_jobservice
2018-07-16 10:50:28 +02:00
REGISTRYCTLBINARYPATH = $( MAKEDEVPATH) /registryctl
REGISTRYCTLBINARYNAME = harbor_registryctl
2017-03-23 05:36:36 +01:00
# configfile
CONFIGPATH = $( MAKEPATH)
CONFIGFILE = harbor.cfg
2017-06-13 11:13:24 +02:00
# prepare parameters
PREPAREPATH = $( TOOLSPATH)
PREPARECMD = prepare
PREPARECMD_PARA = --conf $( CONFIGPATH) /$( CONFIGFILE)
i f e q ( $( NOTARYFLAG ) , t r u e )
PREPARECMD_PARA += --with-notary
e n d i f
i f e q ( $( CLAIRFLAG ) , t r u e )
PREPARECMD_PARA += --with-clair
e n d i f
2018-07-19 10:47:05 +02:00
# append chartmuseum parameters if set
i f e q ( $( CHARTFLAG ) , t r u e )
PREPARECMD_PARA += --with-chartmuseum
e n d i f
2017-06-13 11:13:24 +02:00
2017-03-23 05:36:36 +01:00
# makefile
MAKEFILEPATH_PHOTON = $( MAKEPATH) /photon
# common dockerfile
DOCKERFILEPATH_COMMON = $( MAKEPATH) /common
# docker image name
2018-08-10 08:16:59 +02:00
DOCKERIMAGENAME_ADMINSERVER = goharbor/harbor-adminserver
2018-09-05 09:48:16 +02:00
DOCKERIMAGENAME_PORTAL = goharbor/harbor-portal
2018-09-12 08:38:29 +02:00
DOCKERIMAGENAME_CORE = goharbor/harbor-core
2018-08-10 08:16:59 +02:00
DOCKERIMAGENAME_JOBSERVICE = goharbor/harbor-jobservice
DOCKERIMAGENAME_LOG = goharbor/harbor-log
DOCKERIMAGENAME_DB = goharbor/harbor-db
DOCKERIMAGENAME_CHART_SERVER = goharbor/chartmuseum-photon
DOCKERIMAGENAME_REGCTL = goharbor/harbor-registryctl
2017-12-09 19:53:12 +01:00
2017-03-23 05:36:36 +01:00
# docker-compose files
DOCKERCOMPOSEFILEPATH = $( MAKEPATH)
DOCKERCOMPOSETPLFILENAME = docker-compose.tpl
DOCKERCOMPOSEFILENAME = docker-compose.yml
2017-12-09 19:53:12 +01:00
DOCKERCOMPOSENOTARYTPLFILENAME = docker-compose.notary.tpl
2017-03-23 05:36:36 +01:00
DOCKERCOMPOSENOTARYFILENAME = docker-compose.notary.yml
2017-12-09 19:53:12 +01:00
DOCKERCOMPOSECLAIRTPLFILENAME = docker-compose.clair.tpl
2017-06-13 11:13:24 +02:00
DOCKERCOMPOSECLAIRFILENAME = docker-compose.clair.yml
2018-07-19 10:47:05 +02:00
DOCKERCOMPOSECHARTMUSEUMTPLFILENAME = docker-compose.chartmuseum.tpl
DOCKERCOMPOSECHARTMUSEUMFILENAME = docker-compose.chartmuseum.yml
2017-03-23 05:36:36 +01:00
SEDCMD = $( shell which sed)
2017-06-13 11:13:24 +02:00
# package
2017-03-23 05:36:36 +01:00
TARCMD = $( shell which tar)
ZIPCMD = $( shell which gzip)
DOCKERIMGFILE = harbor
HARBORPKG = harbor
# pushimage
PUSHSCRIPTPATH = $( MAKEPATH)
PUSHSCRIPTNAME = pushimage.sh
REGISTRYUSER = user
REGISTRYPASSWORD = default
2017-06-13 11:13:24 +02:00
# cmds
DOCKERSAVE_PARA = $( DOCKERIMAGENAME_ADMINSERVER) :$( VERSIONTAG) \
2018-09-05 09:48:16 +02:00
$( DOCKERIMAGENAME_PORTAL) :$( VERSIONTAG) \
2018-09-12 08:38:29 +02:00
$( DOCKERIMAGENAME_CORE) :$( VERSIONTAG) \
2017-06-13 11:13:24 +02:00
$( DOCKERIMAGENAME_LOG) :$( VERSIONTAG) \
$( DOCKERIMAGENAME_DB) :$( VERSIONTAG) \
$( DOCKERIMAGENAME_JOBSERVICE) :$( VERSIONTAG) \
2018-07-16 10:50:28 +02:00
$( DOCKERIMAGENAME_REGCTL) :$( VERSIONTAG) \
2018-08-10 08:16:59 +02:00
goharbor/redis-photon:$( REDISVERSION) \
goharbor/nginx-photon:$( NGINXVERSION) goharbor/registry-photon:$( REGISTRYVERSION) -$( VERSIONTAG)
2018-07-26 04:09:22 +02:00
2018-03-21 06:03:49 +01:00
PACKAGE_OFFLINE_PARA = -zcvf harbor-offline-installer-$( PKGVERSIONTAG) .tgz \
2017-06-13 11:13:24 +02:00
$( HARBORPKG) /common/templates $( HARBORPKG) /$( DOCKERIMGFILE) .$( VERSIONTAG) .tar.gz \
2018-09-21 11:20:43 +02:00
$( HARBORPKG) /prepare \
2017-06-13 11:13:24 +02:00
$( HARBORPKG) /LICENSE $( HARBORPKG) /install.sh \
2017-09-27 06:56:57 +02:00
$( HARBORPKG) /harbor.cfg $( HARBORPKG) /$( DOCKERCOMPOSEFILENAME) \
2018-09-03 08:00:38 +02:00
$( HARBORPKG) /open_source_license
2018-07-26 04:09:22 +02:00
2018-03-21 06:03:49 +01:00
PACKAGE_ONLINE_PARA = -zcvf harbor-online-installer-$( PKGVERSIONTAG) .tgz \
2017-06-13 11:13:24 +02:00
$( HARBORPKG) /common/templates $( HARBORPKG) /prepare \
2018-09-21 11:20:43 +02:00
$( HARBORPKG) /LICENSE \
2017-06-13 11:13:24 +02:00
$( HARBORPKG) /install.sh $( HARBORPKG) /$( DOCKERCOMPOSEFILENAME) \
2018-09-03 08:00:38 +02:00
$( HARBORPKG) /harbor.cfg \
2018-07-19 09:47:37 +02:00
$( HARBORPKG) /open_source_license
2018-07-26 04:09:22 +02:00
2017-06-13 11:13:24 +02:00
DOCKERCOMPOSE_LIST = -f $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSEFILENAME)
i f e q ( $( NOTARYFLAG ) , t r u e )
2018-08-10 08:16:59 +02:00
DOCKERSAVE_PARA += goharbor/notary-server-photon:$( NOTARYVERSION) -$( VERSIONTAG) goharbor/notary-signer-photon:$( NOTARYVERSION) -$( VERSIONTAG)
2017-06-13 11:13:24 +02:00
PACKAGE_OFFLINE_PARA += $( HARBORPKG) /$( DOCKERCOMPOSENOTARYFILENAME)
PACKAGE_ONLINE_PARA += $( HARBORPKG) /$( DOCKERCOMPOSENOTARYFILENAME)
DOCKERCOMPOSE_LIST += -f $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSENOTARYFILENAME)
e n d i f
i f e q ( $( CLAIRFLAG ) , t r u e )
2018-08-10 08:16:59 +02:00
DOCKERSAVE_PARA += goharbor/clair-photon:$( CLAIRVERSION) -$( VERSIONTAG)
2017-06-13 11:13:24 +02:00
PACKAGE_OFFLINE_PARA += $( HARBORPKG) /$( DOCKERCOMPOSECLAIRFILENAME)
PACKAGE_ONLINE_PARA += $( HARBORPKG) /$( DOCKERCOMPOSECLAIRFILENAME)
DOCKERCOMPOSE_LIST += -f $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSECLAIRFILENAME)
e n d i f
2017-07-31 12:06:30 +02:00
i f e q ( $( MIGRATORFLAG ) , t r u e )
2018-08-10 08:16:59 +02:00
DOCKERSAVE_PARA += goharbor/harbor-migrator:$( MIGRATORVERSION)
2017-07-31 12:06:30 +02:00
e n d i f
2018-07-19 10:47:05 +02:00
# append chartmuseum parameters if set
i f e q ( $( CHARTFLAG ) , t r u e )
2018-07-26 04:09:22 +02:00
DOCKERSAVE_PARA += $( DOCKERIMAGENAME_CHART_SERVER) :$( CHARTMUSEUMVERSION) -$( VERSIONTAG)
2018-07-19 10:47:05 +02:00
PACKAGE_OFFLINE_PARA += $( HARBORPKG) /$( DOCKERCOMPOSECHARTMUSEUMFILENAME)
PACKAGE_ONLINE_PARA += $( HARBORPKG) /$( DOCKERCOMPOSECHARTMUSEUMFILENAME)
DOCKERCOMPOSE_LIST += -f $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSECHARTMUSEUMFILENAME)
e n d i f
2017-06-13 11:13:24 +02:00
2017-03-23 05:36:36 +01:00
version :
2018-03-23 10:56:29 +01:00
@printf $( UIVERSIONTAG) > $( VERSIONFILEPATH) /$( VERSIONFILENAME) ;
2017-06-13 11:13:24 +02:00
2017-03-23 05:36:36 +01:00
check_environment :
@$( MAKEPATH) /$( CHECKENVCMD)
2018-08-29 12:54:00 +02:00
compile_adminserver :
2017-03-23 05:36:36 +01:00
@echo "compiling binary for adminserver (golang image)..."
@echo $( GOBASEPATH)
@echo $( GOBUILDPATH)
2018-09-03 11:40:26 +02:00
$( DOCKERCMD) run --rm -v $( BUILDPATH) :$( GOBUILDPATH) -w $( GOBUILDPATH_ADMINSERVER) $( GOBUILDIMAGE) $( GOIMAGEBUILD) -o $( GOBUILDMAKEPATH_ADMINSERVER) /$( ADMINSERVERBINARYNAME)
2017-03-23 05:36:36 +01:00
@echo "Done."
2018-09-12 08:38:29 +02:00
compile_core :
@echo "compiling binary for core (golang image)..."
2017-03-23 05:36:36 +01:00
@echo $( GOBASEPATH)
@echo $( GOBUILDPATH)
2018-09-12 08:38:29 +02:00
@$( DOCKERCMD) run --rm -v $( BUILDPATH) :$( GOBUILDPATH) -w $( GOBUILDPATH_CORE) $( GOBUILDIMAGE) $( GOIMAGEBUILD) -o $( GOBUILDMAKEPATH_CORE) /$( CORE_BINARYNAME)
2017-03-23 05:36:36 +01:00
@echo "Done."
2017-06-13 11:13:24 +02:00
2018-08-29 12:54:00 +02:00
compile_jobservice :
2017-03-23 05:36:36 +01:00
@echo "compiling binary for jobservice (golang image)..."
2018-02-27 08:01:14 +01:00
@$( DOCKERCMD) run --rm -v $( BUILDPATH) :$( GOBUILDPATH) -w $( GOBUILDPATH_JOBSERVICE) $( GOBUILDIMAGE) $( GOIMAGEBUILD) -o $( GOBUILDMAKEPATH_JOBSERVICE) /$( JOBSERVICEBINARYNAME)
2017-03-23 05:36:36 +01:00
@echo "Done."
2018-08-29 12:54:00 +02:00
compile_registryctl :
2018-08-09 13:04:35 +02:00
@echo "compiling binary for harbor registry controller (golang image)..."
2018-07-16 10:50:28 +02:00
@$( DOCKERCMD) run --rm -v $( BUILDPATH) :$( GOBUILDPATH) -w $( GOBUILDPATH_REGISTRYCTL) $( GOBUILDIMAGE) $( GOIMAGEBUILD) -o $( GOBUILDMAKEPATH_REGISTRYCTL) /$( REGISTRYCTLBINARYNAME)
@echo "Done."
2018-09-12 08:38:29 +02:00
compile : check_environment compile_adminserver compile_core compile_jobservice compile_registryctl
2017-03-23 05:36:36 +01:00
2017-06-13 11:13:24 +02:00
prepare :
@echo "preparing..."
@$( MAKEPATH) /$( PREPARECMD) $( PREPARECMD_PARA)
2017-12-09 19:53:12 +01:00
build :
2018-09-03 11:40:26 +02:00
make -f $( MAKEFILEPATH_PHOTON) /Makefile build -e DEVFLAG = $( DEVFLAG) \
2017-12-09 19:53:12 +01:00
-e REGISTRYVERSION = $( REGISTRYVERSION) -e NGINXVERSION = $( NGINXVERSION) -e NOTARYVERSION = $( NOTARYVERSION) \
-e CLAIRVERSION = $( CLAIRVERSION) -e CLAIRDBVERSION = $( CLAIRDBVERSION) -e VERSIONTAG = $( VERSIONTAG) \
2018-07-19 17:50:25 +02:00
-e BUILDBIN = $( BUILDBIN) -e REDISVERSION = $( REDISVERSION) -e MIGRATORVERSION = $( MIGRATORVERSION) \
-e CHARTMUSEUMVERSION = $( CHARTMUSEUMVERSION) -e DOCKERIMAGENAME_CHART_SERVER = $( DOCKERIMAGENAME_CHART_SERVER)
2017-06-13 11:13:24 +02:00
2018-07-19 10:47:05 +02:00
modify_composefile : modify_composefile_notary modify_composefile_clair modify_composefile_chartmuseum
2017-03-23 05:36:36 +01:00
@echo "preparing docker-compose file..."
@cp $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSETPLFILENAME) $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSEFILENAME)
2017-12-09 19:53:12 +01:00
@$( SEDCMD) -i 's/__version__/$(VERSIONTAG)/g' $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSEFILENAME)
2018-04-27 11:27:12 +02:00
@$( SEDCMD) -i 's/__postgresql_version__/$(VERSIONTAG)/g' $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSEFILENAME)
2018-01-25 10:34:47 +01:00
@$( SEDCMD) -i 's/__reg_version__/$(REGISTRYVERSION)-$(VERSIONTAG)/g' $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSEFILENAME)
2017-12-09 19:53:12 +01:00
@$( SEDCMD) -i 's/__nginx_version__/$(NGINXVERSION)/g' $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSEFILENAME)
2018-03-30 07:22:10 +02:00
@$( SEDCMD) -i 's/__redis_version__/$(REDISVERSION)/g' $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSEFILENAME)
2017-12-09 19:53:12 +01:00
modify_composefile_notary :
@echo "preparing docker-compose notary file..."
@cp $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSENOTARYTPLFILENAME) $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSENOTARYFILENAME)
@$( SEDCMD) -i 's/__notary_version__/$(NOTARYVERSION)-$(VERSIONTAG)/g' $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSENOTARYFILENAME)
modify_composefile_clair :
@echo "preparing docker-compose clair file..."
@cp $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSECLAIRTPLFILENAME) $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSECLAIRFILENAME)
@$( SEDCMD) -i 's/__postgresql_version__/$(CLAIRDBVERSION)/g' $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSECLAIRFILENAME)
@$( SEDCMD) -i 's/__clair_version__/$(CLAIRVERSION)-$(VERSIONTAG)/g' $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSECLAIRFILENAME)
2017-04-09 14:16:52 +02:00
2018-07-19 10:47:05 +02:00
modify_composefile_chartmuseum :
@echo "preparing docker-compose chartmuseum file..."
@cp $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSECHARTMUSEUMTPLFILENAME) $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSECHARTMUSEUMFILENAME)
@$( SEDCMD) -i 's/__chartmuseum_version__/$(CHARTMUSEUMVERSION)-$(VERSIONTAG)/g' $( DOCKERCOMPOSEFILEPATH) /$( DOCKERCOMPOSECHARTMUSEUMFILENAME)
2017-04-09 14:16:52 +02:00
modify_sourcefiles :
@echo "change mode of source files."
@chmod 600 $( MAKEPATH) /common/templates/notary/notary-signer.key
2017-04-11 07:06:39 +02:00
@chmod 600 $( MAKEPATH) /common/templates/notary/notary-signer.crt
@chmod 600 $( MAKEPATH) /common/templates/notary/notary-signer-ca.crt
2018-09-12 08:38:29 +02:00
@chmod 600 $( MAKEPATH) /common/templates/core/private_key.pem
2017-04-11 07:06:39 +02:00
@chmod 600 $( MAKEPATH) /common/templates/registry/root.crt
2017-06-13 11:13:24 +02:00
2017-12-09 19:53:12 +01:00
install : compile version build modify_sourcefiles prepare modify_composefile start
2017-06-13 11:13:24 +02:00
2017-03-23 05:36:36 +01:00
package_online : modify_composefile
@echo "packing online package ..."
@cp -r make $( HARBORPKG)
@if [ -n " $( REGISTRYSERVER) " ] ; then \
2018-08-10 08:16:59 +02:00
$( SEDCMD) -i 's/image\: goharbor/image\: $(REGISTRYSERVER)\/$(REGISTRYPROJECTNAME)/' \
2017-03-23 05:36:36 +01:00
$( HARBORPKG) /docker-compose.yml ; \
fi
@cp LICENSE $( HARBORPKG) /LICENSE
2018-07-19 09:47:37 +02:00
@cp open_source_license $( HARBORPKG) /open_source_license
2017-12-09 19:53:12 +01:00
2017-06-13 11:13:24 +02:00
@$( TARCMD) $( PACKAGE_ONLINE_PARA)
2017-03-23 05:36:36 +01:00
@rm -rf $( HARBORPKG)
@echo "Done."
2017-06-13 11:13:24 +02:00
2017-12-09 19:53:12 +01:00
package_offline : compile version build modify_sourcefiles modify_composefile
2017-03-23 05:36:36 +01:00
@echo "packing offline package ..."
@cp -r make $( HARBORPKG)
@cp LICENSE $( HARBORPKG) /LICENSE
2018-07-19 09:47:37 +02:00
@cp open_source_license $( HARBORPKG) /open_source_license
2017-03-23 05:36:36 +01:00
2017-06-13 11:13:24 +02:00
@echo "saving harbor docker image"
2017-11-01 11:09:45 +01:00
@$( DOCKERSAVE) $( DOCKERSAVE_PARA) > $( HARBORPKG) /$( DOCKERIMGFILE) .$( VERSIONTAG) .tar
@gzip $( HARBORPKG) /$( DOCKERIMGFILE) .$( VERSIONTAG) .tar
2017-06-13 11:13:24 +02:00
@$( TARCMD) $( PACKAGE_OFFLINE_PARA)
2017-03-23 05:36:36 +01:00
@rm -rf $( HARBORPKG)
@echo "Done."
2017-06-13 11:13:24 +02:00
2018-08-06 07:56:22 +02:00
gosec :
#go get github.com/securego/gosec/cmd/gosec
#go get github.com/dghubble/sling
@echo "run secure go scan ..."
@if [ " $( GOSECRESULTS) " != "" ] ; then \
$( GOPATH) /bin/gosec -fmt= json -out= $( GOSECRESULTS) -quiet ./... | true ; \
else \
$( GOPATH) /bin/gosec -fmt= json -out= harbor_gas_output.json -quiet ./... | true ; \
fi
2018-09-20 05:48:38 +02:00
go_check : misspell golint govet gofmt commentfmt
2018-08-24 07:30:07 +02:00
gofmt :
@echo checking gofmt...
@res= $$ ( gofmt -d -e -s $$ ( find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print) ) ; \
if [ -n " $$ {res} " ] ; then \
echo checking gofmt fail... ; \
echo " $$ {res} " ; \
exit 1; \
fi
2018-09-20 05:48:38 +02:00
commentfmt :
@echo checking comment format...
@res= $$ ( find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print | xargs egrep '(^|\s)\/\/(\S)' ) ; \
if [ -n " $$ {res} " ] ; then \
echo checking comment format fail.. ; \
echo missing whitespace between // and comment body; \
echo " $$ {res} " ; \
exit 1; \
fi
2018-08-24 07:30:07 +02:00
misspell :
@echo checking misspell...
@find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print | xargs misspell -error
golint :
@echo checking golint...
@go list ./... | grep -v -E 'vendor|test' | xargs -L1 fgt golint
govet :
@echo checking govet...
@go list ./... | grep -v -E 'vendor|test' | xargs -L1 go vet
2017-03-23 05:36:36 +01:00
pushimage :
@echo "pushing harbor images ..."
@$( DOCKERTAG) $( DOCKERIMAGENAME_ADMINSERVER) :$( VERSIONTAG) $( REGISTRYSERVER) $( DOCKERIMAGENAME_ADMINSERVER) :$( VERSIONTAG)
@$( PUSHSCRIPTPATH) /$( PUSHSCRIPTNAME) $( REGISTRYSERVER) $( DOCKERIMAGENAME_ADMINSERVER) :$( VERSIONTAG) \
$( REGISTRYUSER) $( REGISTRYPASSWORD) $( REGISTRYSERVER)
@$( DOCKERRMIMAGE) $( REGISTRYSERVER) $( DOCKERIMAGENAME_ADMINSERVER) :$( VERSIONTAG)
2018-09-05 09:48:16 +02:00
@$( DOCKERTAG) $( DOCKERIMAGENAME_PORTAL) :$( VERSIONTAG) $( REGISTRYSERVER) $( DOCKERIMAGENAME_PORTAL) :$( VERSIONTAG)
@$( PUSHSCRIPTPATH) /$( PUSHSCRIPTNAME) $( REGISTRYSERVER) $( DOCKERIMAGENAME_PORTAL) :$( VERSIONTAG) \
$( REGISTRYUSER) $( REGISTRYPASSWORD) $( REGISTRYSERVER)
@$( DOCKERRMIMAGE) $( REGISTRYSERVER) $( DOCKERIMAGENAME_PORTAL) :$( VERSIONTAG)
2018-09-12 08:38:29 +02:00
@$( DOCKERTAG) $( DOCKERIMAGENAME_CORE) :$( VERSIONTAG) $( REGISTRYSERVER) $( DOCKERIMAGENAME_CORE) :$( VERSIONTAG)
@$( PUSHSCRIPTPATH) /$( PUSHSCRIPTNAME) $( REGISTRYSERVER) $( DOCKERIMAGENAME_CORE) :$( VERSIONTAG) \
2017-03-23 05:36:36 +01:00
$( REGISTRYUSER) $( REGISTRYPASSWORD) $( REGISTRYSERVER)
2018-09-12 08:38:29 +02:00
@$( DOCKERRMIMAGE) $( REGISTRYSERVER) $( DOCKERIMAGENAME_CORE) :$( VERSIONTAG)
2017-06-13 11:13:24 +02:00
2017-03-23 05:36:36 +01:00
@$( DOCKERTAG) $( DOCKERIMAGENAME_JOBSERVICE) :$( VERSIONTAG) $( REGISTRYSERVER) $( DOCKERIMAGENAME_JOBSERVICE) :$( VERSIONTAG)
@$( PUSHSCRIPTPATH) /$( PUSHSCRIPTNAME) $( REGISTRYSERVER) $( DOCKERIMAGENAME_JOBSERVICE) :$( VERSIONTAG) \
$( REGISTRYUSER) $( REGISTRYPASSWORD) $( REGISTRYSERVER)
@$( DOCKERRMIMAGE) $( REGISTRYSERVER) $( DOCKERIMAGENAME_JOBSERVICE) :$( VERSIONTAG)
2017-06-13 11:13:24 +02:00
2017-03-23 05:36:36 +01:00
@$( DOCKERTAG) $( DOCKERIMAGENAME_LOG) :$( VERSIONTAG) $( REGISTRYSERVER) $( DOCKERIMAGENAME_LOG) :$( VERSIONTAG)
@$( PUSHSCRIPTPATH) /$( PUSHSCRIPTNAME) $( REGISTRYSERVER) $( DOCKERIMAGENAME_LOG) :$( VERSIONTAG) \
$( REGISTRYUSER) $( REGISTRYPASSWORD) $( REGISTRYSERVER)
@$( DOCKERRMIMAGE) $( REGISTRYSERVER) $( DOCKERIMAGENAME_LOG) :$( VERSIONTAG)
2017-06-13 11:13:24 +02:00
2017-03-23 05:36:36 +01:00
@$( DOCKERTAG) $( DOCKERIMAGENAME_DB) :$( VERSIONTAG) $( REGISTRYSERVER) $( DOCKERIMAGENAME_DB) :$( VERSIONTAG)
@$( PUSHSCRIPTPATH) /$( PUSHSCRIPTNAME) $( REGISTRYSERVER) $( DOCKERIMAGENAME_DB) :$( VERSIONTAG) \
$( REGISTRYUSER) $( REGISTRYPASSWORD) $( REGISTRYSERVER)
@$( DOCKERRMIMAGE) $( REGISTRYSERVER) $( DOCKERIMAGENAME_DB) :$( VERSIONTAG)
2017-06-13 11:13:24 +02:00
2017-03-23 05:36:36 +01:00
start :
@echo "loading harbor images..."
2017-06-13 11:13:24 +02:00
@$( DOCKERCOMPOSECMD) $( DOCKERCOMPOSE_LIST) up -d
2017-03-23 05:36:36 +01:00
@echo "Start complete. You can visit harbor now."
2017-06-13 11:13:24 +02:00
2017-03-23 05:36:36 +01:00
down :
2018-07-19 17:50:25 +02:00
@echo "Please make sure to set -e NOTARYFLAG=true/CLAIRFLAG=true/CHARTFLAG=true if you are using Notary/CLAIR/Chartmuseum in Harbor, otherwise the Notary/CLAIR/Chartmuseum containers cannot be stop automaticlly."
2017-03-23 05:36:36 +01:00
@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..."
2017-06-13 11:13:24 +02:00
@$( DOCKERCOMPOSECMD) $( DOCKERCOMPOSE_LIST) down -v
2017-03-23 05:36:36 +01:00
@echo "Done."
2018-08-01 00:38:23 +02:00
swagger_client :
@echo "Generate swagger client"
wget -q http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.3.1/swagger-codegen-cli-2.3.1.jar -O swagger-codegen-cli.jar
rm -rf harborclient
mkdir harborclient
java -jar swagger-codegen-cli.jar generate -i docs/swagger.yaml -l python -o harborclient
2018-08-16 12:36:27 +02:00
cd harborclient; python ./setup.py install
2018-08-01 00:38:23 +02:00
pip install docker -q
pip freeze
2017-03-23 05:36:36 +01:00
cleanbinary :
@echo "cleaning binary..."
@if [ -f $( ADMINSERVERBINARYPATH) /$( ADMINSERVERBINARYNAME) ] ; then rm $( ADMINSERVERBINARYPATH) /$( ADMINSERVERBINARYNAME) ; fi
2018-09-12 08:38:29 +02:00
@if [ -f $( CORE_BINARYPATH) /$( CORE_BINARYNAME) ] ; then rm $( CORE_BINARYPATH) /$( CORE_BINARYNAME) ; fi
2017-03-23 05:36:36 +01:00
@if [ -f $( JOBSERVICEBINARYPATH) /$( JOBSERVICEBINARYNAME) ] ; then rm $( JOBSERVICEBINARYPATH) /$( JOBSERVICEBINARYNAME) ; fi
cleanimage :
@echo "cleaning image for photon..."
- $( DOCKERRMIMAGE) -f $( DOCKERIMAGENAME_ADMINSERVER) :$( VERSIONTAG)
2018-09-12 08:38:29 +02:00
- $( DOCKERRMIMAGE) -f $( DOCKERIMAGENAME_CORE) :$( VERSIONTAG)
2017-03-23 05:36:36 +01:00
- $( DOCKERRMIMAGE) -f $( DOCKERIMAGENAME_DB) :$( VERSIONTAG)
- $( DOCKERRMIMAGE) -f $( DOCKERIMAGENAME_JOBSERVICE) :$( VERSIONTAG)
- $( DOCKERRMIMAGE) -f $( DOCKERIMAGENAME_LOG) :$( VERSIONTAG)
cleandockercomposefile :
@echo " cleaning $( DOCKERCOMPOSEFILEPATH) /docker-compose.yml "
@if [ -f $( DOCKERCOMPOSEFILEPATH) /docker-compose.yml ] ; then rm $( DOCKERCOMPOSEFILEPATH) /docker-compose.yml ; fi
cleanversiontag :
@echo "cleaning version TAG"
2017-06-13 11:13:24 +02:00
@rm -rf $( VERSIONFILEPATH) /$( VERSIONFILENAME)
2017-03-23 05:36:36 +01:00
cleanpackage :
@echo "cleaning harbor install package"
@if [ -d $( BUILDPATH) /harbor ] ; then rm -rf $( BUILDPATH) /harbor ; fi
2018-01-22 09:43:00 +01:00
@if [ -f $( BUILDPATH) /harbor-online-installer-$( VERSIONTAG) .tgz ] ; \
then rm $( BUILDPATH) /harbor-online-installer-$( VERSIONTAG) .tgz ; fi
@if [ -f $( BUILDPATH) /harbor-offline-installer-$( VERSIONTAG) .tgz ] ; \
then rm $( BUILDPATH) /harbor-offline-installer-$( VERSIONTAG) .tgz ; fi
2017-03-23 05:36:36 +01:00
.PHONY : cleanall
cleanall : cleanbinary cleanimage cleandockercomposefile cleanversiontag cleanpackage
2017-06-13 11:13:24 +02:00
clean :
2017-03-23 05:36:36 +01:00
@echo " make cleanall: remove binary, Harbor images, specific version docker-compose"
@echo " file, specific version tag, online and offline install package"
2018-09-12 08:38:29 +02:00
@echo " make cleanbinary: remove core and jobservice binary"
2017-03-23 05:36:36 +01:00
@echo " make cleanimage: remove Harbor images"
@echo " make cleandockercomposefile: remove specific version docker-compose"
@echo " make cleanversiontag: cleanpackageremove specific version tag"
@echo " make cleanpackage: remove online and offline install package"
all : install