mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-06 11:08:11 +02:00
commit
470649c283
16
.travis.yml
16
.travis.yml
@ -32,9 +32,7 @@ env:
|
|||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- sudo ./tests/hostcfg.sh
|
- sudo ./tests/hostcfg.sh
|
||||||
- cd Deploy
|
- sudo ./make/prepare
|
||||||
- sudo ./prepare
|
|
||||||
- cd ..
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- sudo apt-get update && sudo apt-get install -y libldap2-dev
|
- sudo apt-get update && sudo apt-get install -y libldap2-dev
|
||||||
@ -71,24 +69,24 @@ install:
|
|||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
# create tables and load data
|
# create tables and load data
|
||||||
# - mysql < ./Deploy/db/registry.sql -uroot --verbose
|
# - mysql < ./make/db/registry.sql -uroot --verbose
|
||||||
- sudo sqlite3 /registry.db < ./Deploy/db/registry_sqlite.sql
|
- sudo sqlite3 /registry.db < make/common/db/registry_sqlite.sql
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- sudo ./tests/testprepare.sh
|
- sudo ./tests/testprepare.sh
|
||||||
- docker-compose -f Deploy/docker-compose.test.yml up -d
|
- docker-compose -f ./make/docker-compose.test.yml up -d
|
||||||
- go list ./... | grep -v -E 'vendor|tests' | xargs -L1 fgt golint
|
- go list ./... | grep -v -E 'vendor|tests' | xargs -L1 fgt golint
|
||||||
- go list ./... | grep -v -E 'vendor|tests' | xargs -L1 go vet
|
- go list ./... | grep -v -E 'vendor|tests' | xargs -L1 go vet
|
||||||
- export MYSQL_HOST=$IP
|
- export MYSQL_HOST=$IP
|
||||||
- export REGISTRY_URL=$IP:5000
|
- export REGISTRY_URL=$IP:5000
|
||||||
- echo $REGISTRY_URL
|
- echo $REGISTRY_URL
|
||||||
- ./tests/pushimage.sh
|
- ./tests/pushimage.sh
|
||||||
- ./Deploy/coverage4gotest.sh
|
- ./tests/coverage4gotest.sh
|
||||||
- goveralls -coverprofile=profile.cov -service=travis-ci
|
- goveralls -coverprofile=profile.cov -service=travis-ci
|
||||||
|
|
||||||
- docker-compose -f Deploy/docker-compose.test.yml down
|
- docker-compose -f make/docker-compose.test.yml down
|
||||||
|
|
||||||
- docker-compose -f Deploy/docker-compose.yml up -d
|
- docker-compose -f make/docker-compose.yml up -d
|
||||||
|
|
||||||
- docker ps
|
- docker ps
|
||||||
- go run tests/startuptest.go http://localhost/
|
- go run tests/startuptest.go http://localhost/
|
||||||
|
341
Makefile
Normal file
341
Makefile
Normal file
@ -0,0 +1,341 @@
|
|||||||
|
# Makefile for Harbor project
|
||||||
|
#
|
||||||
|
# Targets:
|
||||||
|
#
|
||||||
|
# all: prepare env, compile binarys, build images and install images
|
||||||
|
# prepare: prepare env
|
||||||
|
# compile: compile ui and jobservice code
|
||||||
|
# compile_golangimage:
|
||||||
|
# compile from golang image
|
||||||
|
# for example: make compile_golangimage -e GOBUILDIMAGE= \
|
||||||
|
# reg-bj.eng.vmware.com/harborrelease/harborgo:1.6.2
|
||||||
|
# compile_ui, compile_jobservice: compile specific binary
|
||||||
|
#
|
||||||
|
# build: build Harbor docker images (defuault: build_photon)
|
||||||
|
# for example: make build -e BASEIMAGE=photon
|
||||||
|
# build_photon: build Harbor docker images from photon bsaeimage
|
||||||
|
# build_ubuntu: build Harbor docker images from ubuntu baseimage
|
||||||
|
#
|
||||||
|
# install: include compile binarys, build images, prepare specific \
|
||||||
|
# version composefile and startup Harbor instance
|
||||||
|
#
|
||||||
|
# start: startup Harbor instance
|
||||||
|
#
|
||||||
|
# down: shutdown Harbor instance
|
||||||
|
#
|
||||||
|
# package_online:
|
||||||
|
# prepare online install package
|
||||||
|
# for example: make package_online -e \
|
||||||
|
# REGISTRYSERVER=reg-bj.eng.vmware.com \
|
||||||
|
# REGISTRYPROJECTNAME=harborrelease
|
||||||
|
# note**: DONT add "/" on end of REGISTRYSERVER.
|
||||||
|
#
|
||||||
|
# package_offline:
|
||||||
|
# prepare offline install package
|
||||||
|
#
|
||||||
|
# pushimage: push Harbor images to specific registry server
|
||||||
|
# for example: make pushimage -e REGISTRYUSER=admin \
|
||||||
|
# REGISTRYPASSWORD=***** \
|
||||||
|
# REGISTRYSERVER=reg-bj.eng.vmware.com/ \
|
||||||
|
# REGISTRYPROJECTNAME=harborrelease
|
||||||
|
# note**: need add "/" on end of REGISTRYSERVER. If not setting \
|
||||||
|
# this value will push images directly to dockerhub.
|
||||||
|
# make pushimage -e REGISTRYUSER=vmware \
|
||||||
|
# REGISTRYPASSWORD=***** \
|
||||||
|
# REGISTRYPROJECTNAME=vmware
|
||||||
|
#
|
||||||
|
# clean: remove binary, Harbor images, specific version docker-compose \
|
||||||
|
# file, specific version tag and online/offline install package
|
||||||
|
# cleanbinary: remove ui and jobservice binary
|
||||||
|
# cleanimage: remove Harbor images
|
||||||
|
# cleandockercomposefile:
|
||||||
|
# remove specific version docker-compose
|
||||||
|
# cleanversiontag:
|
||||||
|
# cleanpackageremove specific version tag
|
||||||
|
# cleanpackage: remove online/offline install package
|
||||||
|
#
|
||||||
|
# all: install
|
||||||
|
#
|
||||||
|
# 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 \
|
||||||
|
# files with specific TAG.
|
||||||
|
|
||||||
|
SHELL := /bin/bash
|
||||||
|
BUILDPATH=$(CURDIR)
|
||||||
|
MAKEPATH=$(BUILDPATH)/make
|
||||||
|
MAKEDEVPATH=$(MAKEPATH)/dev
|
||||||
|
SRCPATH=./src
|
||||||
|
TOOLSPATH=$(BUILDPATH)/tools
|
||||||
|
GOBASEPATH=/go/src/github.com/vmware
|
||||||
|
CHECKENVCMD=checkenv.sh
|
||||||
|
BASEIMAGE=photon
|
||||||
|
COMPILETAG=compile_normal
|
||||||
|
REGISTRYSERVER=
|
||||||
|
REGISTRYPROJECTNAME=vmware
|
||||||
|
|
||||||
|
# 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
|
||||||
|
GOBUILDIMAGE=reg.mydomain.com/library/harborgo[:tag]
|
||||||
|
GOBUILDPATH=$(GOBASEPATH)/harbor
|
||||||
|
GOBUILDPATH_UI=$(GOBUILDPATH)/ui
|
||||||
|
GOBUILDPATH_JOBSERVICE=$(GOBUILDPATH)/jobservice
|
||||||
|
GOBUILDMAKEPATH=$(GOBUILDPATH)/make
|
||||||
|
GOBUILDMAKEPATH_UI=$(GOBUILDMAKEPATH)/ui
|
||||||
|
GOBUILDMAKEPATH_JOBSERVICE=$(GOBUILDMAKEPATH)/jobservice
|
||||||
|
|
||||||
|
# binary
|
||||||
|
UISOURCECODE=$(SRCPATH)/ui
|
||||||
|
UIBINARYPATH=$(MAKEDEVPATH)/ui
|
||||||
|
UIBINARYNAME=harbor_ui
|
||||||
|
JOBSERVICESOURCECODE=$(SRCPATH)/jobservice
|
||||||
|
JOBSERVICEBINARYPATH=$(MAKEDEVPATH)/jobservice
|
||||||
|
JOBSERVICEBINARYNAME=harbor_jobservice
|
||||||
|
|
||||||
|
# prepare parameters
|
||||||
|
PREPAREPATH=$(TOOLSPATH)
|
||||||
|
PREPARECMD=prepare
|
||||||
|
|
||||||
|
# configfile
|
||||||
|
CONFIGPATH=$(MAKEPATH)
|
||||||
|
CONFIGFILE=harbor.cfg
|
||||||
|
|
||||||
|
# makefile
|
||||||
|
MAKEFILEPATH_PHOTON=$(MAKEPATH)/photon
|
||||||
|
MAKEFILEPATH_UBUNTU=$(MAKEPATH)/ubuntu
|
||||||
|
|
||||||
|
# common dockerfile
|
||||||
|
DOCKERFILEPATH_COMMON=$(MAKEPATH)/common
|
||||||
|
DOCKERFILEPATH_DB=$(DOCKERFILEPATH_COMMON)/db
|
||||||
|
DOCKERFILENAME_DB=Dockerfile
|
||||||
|
|
||||||
|
# docker image name
|
||||||
|
DOCKERIMAGENAME_UI=$(REGISTRYPROJECTNAME)/harbor-ui
|
||||||
|
DOCKERIMAGENAME_JOBSERVICE=$(REGISTRYPROJECTNAME)/harbor-jobservice
|
||||||
|
DOCKERIMAGENAME_LOG=$(REGISTRYPROJECTNAME)/harbor-log
|
||||||
|
DOCKERIMAGENAME_DB=$(REGISTRYPROJECTNAME)/harbor-db
|
||||||
|
|
||||||
|
|
||||||
|
# docker-compose files
|
||||||
|
DOCKERCOMPOSEFILEPATH=$(MAKEPATH)
|
||||||
|
DOCKERCOMPOSEFILENAME=docker-compose.yml
|
||||||
|
|
||||||
|
# version prepare
|
||||||
|
VERSIONFILEPATH=$(SRCPATH)/ui/views/sections
|
||||||
|
VERSIONFILENAME=header-content.htm
|
||||||
|
GITCMD=$(shell which git)
|
||||||
|
GITTAG=$(GITCMD) describe --tags
|
||||||
|
VERSIONTAG=$(shell $(GITTAG))
|
||||||
|
SEDCMD=$(shell which sed)
|
||||||
|
|
||||||
|
# package
|
||||||
|
TARCMD=$(shell which tar)
|
||||||
|
ZIPCMD=$(shell which gzip)
|
||||||
|
DOCKERIMGFILE=harbor
|
||||||
|
HARBORPKG=harbor
|
||||||
|
|
||||||
|
# pushimage
|
||||||
|
PUSHSCRIPTPATH=$(MAKEPATH)
|
||||||
|
PUSHSCRIPTNAME=pushimage.sh
|
||||||
|
REGISTRYUSER=user
|
||||||
|
REGISTRYPASSWORD=default
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
version:
|
||||||
|
@$(SEDCMD) -i 's/version=\"{{.Version}}\"/version=\"$(VERSIONTAG)\"/' -i $(VERSIONFILEPATH)/$(VERSIONFILENAME)
|
||||||
|
|
||||||
|
check_environment:
|
||||||
|
@$(MAKEPATH)/$(CHECKENVCMD)
|
||||||
|
|
||||||
|
compile_ui:
|
||||||
|
@echo "compiling binary for ui..."
|
||||||
|
$(GOBUILD) -o $(UIBINARYPATH)/$(UIBINARYNAME) $(UISOURCECODE)
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
compile_jobservice:
|
||||||
|
@echo "compiling binary for jobservice..."
|
||||||
|
$(GOBUILD) -o $(JOBSERVICEBINARYPATH)/$(JOBSERVICEBINARYNAME) $(JOBSERVICESOURCECODE)
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
compile_normal: compile_ui compile_jobservice
|
||||||
|
|
||||||
|
compile_golangimage:
|
||||||
|
@echo "pulling golang build base image"
|
||||||
|
$(DOCKERPULL) $(GOBUILDIMAGE)
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
@echo "compiling binary for ui (golang image)..."
|
||||||
|
@echo $(GOBASEPATH)
|
||||||
|
@echo $(GOBUILDPATH)
|
||||||
|
$(DOCKERCMD) run --rm -v $(BUILDPATH):$(GOBUILDPATH) -w $(GOBUILDPATH_UI) $(GOBUILDIMAGE) $(GOBUILD) -v -o $(GOBUILDMAKEPATH_UI)/$(UIBINARYNAME)
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
@echo "compiling binary for jobservice (golang image)..."
|
||||||
|
$(DOCKERCMD) run --rm -v $(BUILDPATH):$(GOBUILDPATH) -w $(GOBUILDPATH_JOBSERVICE) $(GOBUILDIMAGE) $(GOBUILD) -v -o $(GOBUILDMAKEPATH_JOBSERVICE)/$(JOBSERVICEBINARYNAME)
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
compile:check_environment $(COMPILETAG)
|
||||||
|
|
||||||
|
prepare:
|
||||||
|
@echo "preparing..."
|
||||||
|
$(MAKEPATH)/$(PREPARECMD) -conf $(CONFIGPATH)/$(CONFIGFILE)
|
||||||
|
|
||||||
|
build_common: prepare version
|
||||||
|
@echo "buildging db container for photon..."
|
||||||
|
cd $(DOCKERFILEPATH_DB) && $(DOCKERBUILD) -f $(DOCKERFILENAME_DB) -t $(DOCKERIMAGENAME_DB):$(VERSIONTAG) .
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
@echo "pulling nginx and registry..."
|
||||||
|
$(DOCKERPULL) registry:2.5.0
|
||||||
|
$(DOCKERPULL) nginx:1.9
|
||||||
|
|
||||||
|
build_photon: build_common
|
||||||
|
make -f $(MAKEFILEPATH_PHOTON)/Makefile build
|
||||||
|
|
||||||
|
build_ubuntu: build_common
|
||||||
|
make -f $(MAKEFILEPATH_UBUNTU)/Makefile build
|
||||||
|
|
||||||
|
build: build_$(BASEIMAGE)
|
||||||
|
|
||||||
|
|
||||||
|
modify_composefile:
|
||||||
|
@echo "preparing tag:$(VERSIONTAG) docker-compose file..."
|
||||||
|
@cp $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSEFILENAME) $(DOCKERCOMPOSEFILEPATH)/docker-compose.$(VERSIONTAG).yml
|
||||||
|
@$(SEDCMD) -i 's/image\: vmware.*/&:$(VERSIONTAG)/g' $(DOCKERCOMPOSEFILEPATH)/docker-compose.$(VERSIONTAG).yml
|
||||||
|
|
||||||
|
install: compile build modify_composefile
|
||||||
|
@echo "loading harbor images..."
|
||||||
|
$(DOCKERCOMPOSECMD) -f $(DOCKERCOMPOSEFILEPATH)/docker-compose.$(VERSIONTAG).yml up -d
|
||||||
|
@echo "Install complete. You can visit harbor now."
|
||||||
|
|
||||||
|
package_online: modify_composefile
|
||||||
|
@echo "packing online package ..."
|
||||||
|
@cp -r make $(HARBORPKG)
|
||||||
|
@$(SEDCMD) -i 's/image\: vmware/image\: $(REGISTRYSERVER)\/$(REGISTRYPROJECTNAME)/' $(HARBORPKG)/docker-compose.$(VERSIONTAG).yml
|
||||||
|
|
||||||
|
@cp LICENSE $(HARBORPKG)/LICENSE
|
||||||
|
@cp NOTICE $(HARBORPKG)/NOTICE
|
||||||
|
@$(TARCMD) -zcvf harbor-online-installer-$(VERSIONTAG).tgz \
|
||||||
|
--exclude=$(HARBORPKG)/common/db --exclude=$(HARBORPKG)/ubuntu \
|
||||||
|
--exclude=$(HARBORPKG)/photon --exclude=$(HARBORPKG)/kubernetes \
|
||||||
|
--exclude=$(HARBORPKG)/dev --exclude=docker-compose.yml \
|
||||||
|
--exclude=$(HARBORPKG)/checkenv.sh \
|
||||||
|
--exclude=$(HARBORPKG)/jsminify.sh \
|
||||||
|
--exclude=$(HARBORPKG)/pushimage.sh \
|
||||||
|
$(HARBORPKG)
|
||||||
|
|
||||||
|
@rm -rf $(HARBORPKG)
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
package_offline: compile build modify_composefile
|
||||||
|
@echo "packing offline package ..."
|
||||||
|
@cp -r make $(HARBORPKG)
|
||||||
|
|
||||||
|
@cp LICENSE $(HARBORPKG)/LICENSE
|
||||||
|
@cp NOTICE $(HARBORPKG)/NOTICE
|
||||||
|
@echo "saving harbor docker image"
|
||||||
|
$(DOCKERSAVE) -o $(HARBORPKG)/$(DOCKERIMGFILE).$(VERSIONTAG).tgz \
|
||||||
|
$(DOCKERIMAGENAME_UI):$(VERSIONTAG) \
|
||||||
|
$(DOCKERIMAGENAME_LOG):$(VERSIONTAG) \
|
||||||
|
$(DOCKERIMAGENAME_DB):$(VERSIONTAG) \
|
||||||
|
$(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG) \
|
||||||
|
nginx:1.9.0 registry:2.5.0
|
||||||
|
|
||||||
|
@$(TARCMD) -zcvf harbor-offline-installer-$(VERSIONTAG).tgz \
|
||||||
|
--exclude=$(HARBORPKG)/common/db --exclude=$(HARBORPKG)/ubuntu \
|
||||||
|
--exclude=$(HARBORPKG)/photon --exclude=$(HARBORPKG)/kubernetes \
|
||||||
|
--exclude=$(HARBORPKG)/dev --exclude=docker-compose.yml \
|
||||||
|
--exclude=$(HARBORPKG)/checkenv.sh \
|
||||||
|
--exclude=$(HARBORPKG)/jsminify.sh \
|
||||||
|
--exclude=$(HARBORPKG)/pushimage.sh \
|
||||||
|
$(HARBORPKG)
|
||||||
|
|
||||||
|
@rm -rf $(HARBORPKG)
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
pushimage:
|
||||||
|
@echo "pushing harbor images ..."
|
||||||
|
@$(DOCKERTAG) $(DOCKERIMAGENAME_UI):$(VERSIONTAG) $(REGISTRYSERVER)$(DOCKERIMAGENAME_UI):$(VERSIONTAG)
|
||||||
|
@$(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(REGISTRYSERVER)$(DOCKERIMAGENAME_UI):$(VERSIONTAG) \
|
||||||
|
$(REGISTRYUSER) $(REGISTRYPASSWORD) $(REGISTRYSERVER)
|
||||||
|
@$(DOCKERRMIMAGE) $(REGISTRYSERVER)$(DOCKERIMAGENAME_UI):$(VERSIONTAG)
|
||||||
|
|
||||||
|
@$(DOCKERTAG) $(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG) $(REGISTRYSERVER)$(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG)
|
||||||
|
@$(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(REGISTRYSERVER)$(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG) \
|
||||||
|
$(REGISTRYUSER) $(REGISTRYPASSWORD) $(REGISTRYSERVER)
|
||||||
|
@$(DOCKERRMIMAGE) $(REGISTRYSERVER)$(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG)
|
||||||
|
|
||||||
|
@$(DOCKERTAG) $(DOCKERIMAGENAME_LOG):$(VERSIONTAG) $(REGISTRYSERVER)$(DOCKERIMAGENAME_LOG):$(VERSIONTAG)
|
||||||
|
@$(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(REGISTRYSERVER)$(DOCKERIMAGENAME_LOG):$(VERSIONTAG) \
|
||||||
|
$(REGISTRYUSER) $(REGISTRYPASSWORD) $(REGISTRYSERVER)
|
||||||
|
@$(DOCKERRMIMAGE) $(REGISTRYSERVER)$(DOCKERIMAGENAME_LOG):$(VERSIONTAG)
|
||||||
|
|
||||||
|
@$(DOCKERTAG) $(DOCKERIMAGENAME_DB):$(VERSIONTAG) $(REGISTRYSERVER)$(DOCKERIMAGENAME_DB):$(VERSIONTAG)
|
||||||
|
@$(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(REGISTRYSERVER)$(DOCKERIMAGENAME_DB):$(VERSIONTAG) \
|
||||||
|
$(REGISTRYUSER) $(REGISTRYPASSWORD) $(REGISTRYSERVER)
|
||||||
|
@$(DOCKERRMIMAGE) $(REGISTRYSERVER)$(DOCKERIMAGENAME_DB):$(VERSIONTAG)
|
||||||
|
|
||||||
|
start:
|
||||||
|
@echo "loading harbor images..."
|
||||||
|
@$(DOCKERCOMPOSECMD) -f $(DOCKERCOMPOSEFILEPATH)/docker-compose.$(VERSIONTAG).yml up -d
|
||||||
|
@echo "Start complete. You can visit harbor now."
|
||||||
|
|
||||||
|
down:
|
||||||
|
@echo "stoping harbor instance..."
|
||||||
|
@$(DOCKERCOMPOSECMD) -f $(DOCKERCOMPOSEFILEPATH)/docker-compose.yml down
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
cleanbinary:
|
||||||
|
@echo "cleaning binary..."
|
||||||
|
@if [ -f $(UIBINARYPATH)/$(UIBINARYNAME) ] ; then rm $(UIBINARYPATH)/$(UIBINARYNAME) ; fi
|
||||||
|
@if [ -f $(JOBSERVICEBINARYPATH)/$(JOBSERVICEBINARYNAME) ] ; then rm $(JOBSERVICEBINARYPATH)/$(JOBSERVICEBINARYNAME) ; fi
|
||||||
|
|
||||||
|
cleanimage:
|
||||||
|
@echo "cleaning image for photon..."
|
||||||
|
- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_UI):$(VERSIONTAG)
|
||||||
|
- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_DB):$(VERSIONTAG)
|
||||||
|
- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG)
|
||||||
|
- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_LOG):$(VERSIONTAG)
|
||||||
|
- $(DOCKERRMIMAGE) -f registry:2.5.0
|
||||||
|
- $(DOCKERRMIMAGE) -f nginx:1.9
|
||||||
|
|
||||||
|
cleandockercomposefile:
|
||||||
|
@echo "cleaning $(DOCKERCOMPOSEFILEPATH)/docker-compose.$(VERSIONTAG).yml"
|
||||||
|
@if [ -f $(DOCKERCOMPOSEFILEPATH)/docker-compose.$(VERSIONTAG).yml ] ; then rm $(DOCKERCOMPOSEFILEPATH)/docker-compose.$(VERSIONTAG).yml ; fi
|
||||||
|
|
||||||
|
cleanversiontag:
|
||||||
|
@echo "cleaning version TAG"
|
||||||
|
@$(SEDCMD) -i 's/version=\"$(VERSIONTAG)\"/version=\"{{.Version}}\"/' -i $(VERSIONFILEPATH)/$(VERSIONFILENAME)
|
||||||
|
|
||||||
|
cleanpackage:
|
||||||
|
@echo "cleaning harbor install package"
|
||||||
|
@if [ -d $(BUILDPATH)/harbor ] ; then rm -rf $(BUILDPATH)/harbor ; fi
|
||||||
|
@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
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean: cleanbinary cleanimage cleandockercomposefile cleanversiontag cleanpackage
|
||||||
|
|
||||||
|
all: install
|
||||||
|
|
@ -29,12 +29,12 @@ On an Internet connected host, Harbor can be easily installed via docker-compose
|
|||||||
```sh
|
```sh
|
||||||
$ git clone https://github.com/vmware/harbor
|
$ git clone https://github.com/vmware/harbor
|
||||||
```
|
```
|
||||||
2. Edit the file **Deploy/harbor.cfg**, make necessary configuration changes such as hostname, admin password and mail server. Refer to [Installation and Configuration Guide](docs/installation_guide.md) for more info.
|
2. Edit the file **make/harbor.cfg**, make necessary configuration changes such as hostname, admin password and mail server. Refer to [Installation and Configuration Guide](docs/installation_guide.md) for more info.
|
||||||
|
|
||||||
|
|
||||||
3. Install Harbor with the following commands. Note that the docker-compose process can take a while.
|
3. Install Harbor with the following commands. Note that the docker-compose process can take a while.
|
||||||
```sh
|
```sh
|
||||||
$ cd Deploy
|
$ cd make
|
||||||
|
|
||||||
$ ./prepare
|
$ ./prepare
|
||||||
Generated configuration file: ./config/ui/env
|
Generated configuration file: ./config/ui/env
|
||||||
|
@ -14,7 +14,7 @@ Configure security connection between Harbor and Docker client.
|
|||||||
[Upgrade and Data Migration Guide](migration_guide.md)
|
[Upgrade and Data Migration Guide](migration_guide.md)
|
||||||
Data migration may be needed when upgrading Harbor to a newer version.
|
Data migration may be needed when upgrading Harbor to a newer version.
|
||||||
|
|
||||||
[Deploy Harbor on Kubernetes](kubernetes_deployment.md)
|
[make Harbor on Kubernetes](kubernetes_deployment.md)
|
||||||
Guide to deploy Harbor on Kubenetes. (maintained by community)
|
Guide to deploy Harbor on Kubenetes. (maintained by community)
|
||||||
|
|
||||||
### Developer documents
|
### Developer documents
|
||||||
@ -31,7 +31,7 @@ How to add your local language to Harbor.
|
|||||||
|
|
||||||
[Python SDK](../contrib/sdk/harbor-py) (by community)
|
[Python SDK](../contrib/sdk/harbor-py) (by community)
|
||||||
|
|
||||||
[Deploying Harbor using Docker Machine](../contrib/deploying_using_docker_machine.md) ( by community)
|
[makeing Harbor using Docker Machine](../contrib/deploying_using_docker_machine.md) ( by community)
|
||||||
|
|
||||||
[Configuring Harbor as a local registry mirror](../contrib/Configure_mirror.md) (by community)
|
[Configuring Harbor as a local registry mirror](../contrib/Configure_mirror.md) (by community)
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ How to add your local language to Harbor.
|
|||||||
|
|
||||||
[Overall Architecture of Harbor Registry](http://www.compare-review-information.com/overall-architecture-of-harbor-registry/)
|
[Overall Architecture of Harbor Registry](http://www.compare-review-information.com/overall-architecture-of-harbor-registry/)
|
||||||
|
|
||||||
[Deploying a Private Secured Docker Registry in 15 Minutes](http://alexanderzeitler.com/articles/deploying-a-private-secured-docker-registry-within-15-minutes/)
|
[makeing a Private Secured Docker Registry in 15 Minutes](http://alexanderzeitler.com/articles/deploying-a-private-secured-docker-registry-within-15-minutes/)
|
||||||
|
|
||||||
[Docker Private Registry Using Harbor](https://blog.imaginea.com/docker-private-registry-using-harbor-2/)
|
[Docker Private Registry Using Harbor](https://blog.imaginea.com/docker-private-registry-using-harbor-2/)
|
||||||
|
|
||||||
|
@ -45,9 +45,9 @@ If you're using **IP** to connect your registry host, you may instead run the co
|
|||||||
openssl ca -in yourdomain.com.csr -out yourdomain.com.crt -cert ca.crt -keyfile ca.key -extfile extfile.cnf -outdir .
|
openssl ca -in yourdomain.com.csr -out yourdomain.com.crt -cert ca.crt -keyfile ca.key -extfile extfile.cnf -outdir .
|
||||||
```
|
```
|
||||||
##Configuration of Nginx
|
##Configuration of Nginx
|
||||||
After obtaining the **yourdomain.com.crt** and **yourdomain.com.key** files, change the directory to Deploy/config/nginx in Harbor project.
|
After obtaining the **yourdomain.com.crt** and **yourdomain.com.key** files, change the directory to make/config/nginx in Harbor project.
|
||||||
```
|
```
|
||||||
cd Deploy/config/nginx
|
cd make/config/nginx
|
||||||
```
|
```
|
||||||
Create a new directory cert/, if it does not exist. Then copy **yourdomain.com.crt** and **yourdomain.com.key** to cert/, e.g. :
|
Create a new directory cert/, if it does not exist. Then copy **yourdomain.com.crt** and **yourdomain.com.key** to cert/, e.g. :
|
||||||
```
|
```
|
||||||
@ -87,7 +87,7 @@ Then look for the SSL section to make sure the files of your certificates match
|
|||||||
Save your changes in nginx.conf.
|
Save your changes in nginx.conf.
|
||||||
|
|
||||||
##Installation of Harbor
|
##Installation of Harbor
|
||||||
Next, edit the file Deploy/harbor.cfg , update the hostname and the protocol:
|
Next, edit the file make/harbor.cfg , update the hostname and the protocol:
|
||||||
```
|
```
|
||||||
#set hostname
|
#set hostname
|
||||||
hostname = reg.yourdomain.com
|
hostname = reg.yourdomain.com
|
||||||
|
@ -34,9 +34,9 @@ From time to time, you may need to mannually test Harbor REST API. You can deplo
|
|||||||
```sh
|
```sh
|
||||||
./prepare-swagger.sh
|
./prepare-swagger.sh
|
||||||
```
|
```
|
||||||
* Change the directory to _Deploy_
|
* Change the directory to _make_
|
||||||
```sh
|
```sh
|
||||||
cd ../Deploy
|
cd ../make
|
||||||
```
|
```
|
||||||
* Edit the _docker-compose.yml_ file.
|
* Edit the _docker-compose.yml_ file.
|
||||||
```sh
|
```sh
|
||||||
@ -51,8 +51,8 @@ ui:
|
|||||||
- ./config/ui/app.conf:/etc/ui/app.conf
|
- ./config/ui/app.conf:/etc/ui/app.conf
|
||||||
- ./config/ui/private_key.pem:/etc/ui/private_key.pem
|
- ./config/ui/private_key.pem:/etc/ui/private_key.pem
|
||||||
## add two lines as below ##
|
## add two lines as below ##
|
||||||
- ../static/vendors/swagger-ui-2.1.4/dist:/go/bin/static/vendors/swagger
|
- ../../src/ui/static/vendors/swagger-ui-2.1.4/dist:/go/bin/static/vendors/swagger
|
||||||
- ../static/resources/yaml/swagger.yaml:/go/bin/static/resources/yaml/swagger.yaml
|
- ../../src/ui/static/resources/yaml/swagger.yaml:/go/bin/static/resources/yaml/swagger.yaml
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
* Rebuild Harbor project
|
* Rebuild Harbor project
|
||||||
|
@ -50,7 +50,7 @@ $ cp /root/cert/private_key.pem private_key.pem
|
|||||||
$ cp /root/cert/root.crt ../registry/root.crt
|
$ cp /root/cert/root.crt ../registry/root.crt
|
||||||
```
|
```
|
||||||
|
|
||||||
5.After these, go back to the Deploy directory, you can start Harbor using following command:
|
5.After these, go back to the make directory, you can start Harbor using following command:
|
||||||
```
|
```
|
||||||
$ docker-compose up -d
|
$ docker-compose up -d
|
||||||
```
|
```
|
||||||
|
@ -45,14 +45,14 @@
|
|||||||
|
|
||||||
5. Add the new language to the `app.conf` file.
|
5. Add the new language to the `app.conf` file.
|
||||||
|
|
||||||
In the file `Deploy/config/ui/app.conf`, append a new item to the configuration section.
|
In the file `make/config/ui/app.conf`, append a new item to the configuration section.
|
||||||
```
|
```
|
||||||
[lang]
|
[lang]
|
||||||
types = en-US|zh-CN|<language>-<locale>
|
types = en-US|zh-CN|<language>-<locale>
|
||||||
names = en-US|zh-CN|<language>-<locale>
|
names = en-US|zh-CN|<language>-<locale>
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Next, change to `Deploy/` directory, rebuild and restart the Harbor by the below command:
|
6. Next, change to `make/` directory, rebuild and restart the Harbor by the below command:
|
||||||
```
|
```
|
||||||
docker-compose down
|
docker-compose down
|
||||||
docker-compose up --build -d
|
docker-compose up --build -d
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
By default, Harbor not only build images according to Dockerfile but also pull images from Docker Hub. For the reason we all know, it is difficult for Chinese Harbor users to pull images from the Docker Hub. We put images on daocloud.io platform, we'll put images on other platforms later. If you have difficulty to pull images from Docker Hub, or you think it wastes too much time to build images. We recommend you to use the following way to accelerate the pulling procedure(make sure you're in the harbor diectory):
|
By default, Harbor not only build images according to Dockerfile but also pull images from Docker Hub. For the reason we all know, it is difficult for Chinese Harbor users to pull images from the Docker Hub. We put images on daocloud.io platform, we'll put images on other platforms later. If you have difficulty to pull images from Docker Hub, or you think it wastes too much time to build images. We recommend you to use the following way to accelerate the pulling procedure(make sure you're in the harbor diectory):
|
||||||
```
|
```
|
||||||
$ cd contrib
|
$ cd contrib
|
||||||
$ cp docker-compose.yml.daocloud ../Deploy
|
$ cp docker-compose.yml.daocloud ../make
|
||||||
$ cd ../Deploy
|
$ cd ../make
|
||||||
$ mv docker-compose.yml docker-compose.yml.bak
|
$ mv docker-compose.yml docker-compose.yml.bak
|
||||||
$ mv docker-compose.yml.daocloud docker-compose.yml
|
$ mv docker-compose.yml.daocloud docker-compose.yml
|
||||||
$ docker-compose up -d
|
$ docker-compose up -d
|
||||||
|
@ -7,7 +7,7 @@ Harbor can be installed by one of two installers:
|
|||||||
|
|
||||||
Both installers can be downloaded from the [release page](https://github.com/vmware/harbor/releases). The installation process of both installers are the same, this guide describes the steps to install and configure Harbor.
|
Both installers can be downloaded from the [release page](https://github.com/vmware/harbor/releases). The installation process of both installers are the same, this guide describes the steps to install and configure Harbor.
|
||||||
|
|
||||||
In addition, the deployment instructions on Kubernetes has been created by the community. Refer to [Deploy Harbor on Kubernetes](kubernetes_deployment.md) for details.
|
In addition, the deployment instructions on Kubernetes has been created by the community. Refer to [make Harbor on Kubernetes](kubernetes_deployment.md) for details.
|
||||||
|
|
||||||
## Prerequisites for the target host
|
## Prerequisites for the target host
|
||||||
Harbor is deployed as several Docker containers, and, therefore, can be deployed on any Linux distribution that supports Docker. The target host requires Python, Docker, and Docker Compose to be installed.
|
Harbor is deployed as several Docker containers, and, therefore, can be deployed on any Linux distribution that supports Docker. The target host requires Python, Docker, and Docker Compose to be installed.
|
||||||
@ -281,7 +281,7 @@ $ sudo install.sh
|
|||||||
If a container is not in **UP** state, check the log file of that container in directory ```/var/log/harbor```. For example, if the container ```harbor_ui_1``` is not running, you should look at the log file ```docker_ui.log```.
|
If a container is not in **UP** state, check the log file of that container in directory ```/var/log/harbor```. For example, if the container ```harbor_ui_1``` is not running, you should look at the log file ```docker_ui.log```.
|
||||||
|
|
||||||
|
|
||||||
2.When setting up Harbor behind an nginx proxy or elastic load balancing, look for the line below, in `Deploy/config/nginx/nginx.conf` and remove it from the sections if the proxy already has similar settings: `location /`, `location /v2/` and `location /service/`.
|
2.When setting up Harbor behind an nginx proxy or elastic load balancing, look for the line below, in `make/config/nginx/nginx.conf` and remove it from the sections if the proxy already has similar settings: `location /`, `location /v2/` and `location /service/`.
|
||||||
```
|
```
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
```
|
```
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
## Deploying Harbor on Kubernetes
|
## makeing Harbor on Kubernetes
|
||||||
To deploy Harbor on Kubernetes, it requires some additional steps because
|
To deploy Harbor on Kubernetes, it requires some additional steps because
|
||||||
1. When Harbor registry uses https, so we need cert or workaround to avoid errors like this:
|
1. When Harbor registry uses https, so we need cert or workaround to avoid errors like this:
|
||||||
```
|
```
|
||||||
@ -24,13 +24,13 @@ To deploy Harbor on Kubernetes, it requires some additional steps because
|
|||||||
- Rebuild the registry image with the service IP after the service is created and use ```kubectl rolling-update``` to update to the new image.
|
- Rebuild the registry image with the service IP after the service is created and use ```kubectl rolling-update``` to update to the new image.
|
||||||
|
|
||||||
|
|
||||||
To start Harbor on Kubernetes, you first need to build the docker images. The docker images for deploying Harbor on Kubernetes depends on the docker images to deploy Harbor with docker-compose. So the first step is to build docker images with docker-compose. Before actually building the images, you need to first adjust the [configuration](https://github.com/vmware/harbor/blob/master/Deploy/harbor.cfg):
|
To start Harbor on Kubernetes, you first need to build the docker images. The docker images for deploying Harbor on Kubernetes depends on the docker images to deploy Harbor with docker-compose. So the first step is to build docker images with docker-compose. Before actually building the images, you need to first adjust the [configuration](https://github.com/vmware/harbor/blob/master/make/harbor.cfg):
|
||||||
- Change the [hostname](https://github.com/vmware/harbor/blob/master/Deploy/harbor.cfg#L5) to ```localhost```
|
- Change the [hostname](https://github.com/vmware/harbor/blob/master/make/harbor.cfg#L5) to ```localhost```
|
||||||
- Adjust the [email settings](https://github.com/vmware/harbor/blob/master/Deploy/harbor.cfg#L11) according to your needs.
|
- Adjust the [email settings](https://github.com/vmware/harbor/blob/master/make/harbor.cfg#L11) according to your needs.
|
||||||
|
|
||||||
Then you can run the following commends to build docker images:
|
Then you can run the following commends to build docker images:
|
||||||
```
|
```
|
||||||
cd Deploy
|
cd make
|
||||||
./prepare
|
./prepare
|
||||||
docker-compose build
|
docker-compose build
|
||||||
docker build -f kubernetes/dockerfiles/proxy-dockerfile -t {your_account}/proxy .
|
docker build -f kubernetes/dockerfiles/proxy-dockerfile -t {your_account}/proxy .
|
||||||
@ -45,21 +45,21 @@ docker push {your_account}/deploy_mysql
|
|||||||
|
|
||||||
where "your_account" is your own registry. Then you need to update the "image" field in the ```*-rc.yaml``` files at:
|
where "your_account" is your own registry. Then you need to update the "image" field in the ```*-rc.yaml``` files at:
|
||||||
```
|
```
|
||||||
Deploy/kubernetes/mysql-rc.yaml
|
make/kubernetes/mysql-rc.yaml
|
||||||
Deploy/kubernetes/proxy-rc.yaml
|
make/kubernetes/proxy-rc.yaml
|
||||||
Deploy/kubernetes/registry-rc.yaml
|
make/kubernetes/registry-rc.yaml
|
||||||
Deploy/kubernetes/ui-rc.yaml
|
make/kubernetes/ui-rc.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
Further more, the following configuration could be changed according to your need:
|
Further more, the following configuration could be changed according to your need:
|
||||||
- **harbor_admin_password**: The password for the administrator of Harbor, by default the password is Harbor12345. You can changed it [here](https://github.com/vmware/harbor/blob/master/Deploy/kubernetes/ui-rc.yaml#L36).
|
- **harbor_admin_password**: The password for the administrator of Harbor, by default the password is Harbor12345. You can changed it [here](https://github.com/vmware/harbor/blob/master/make/kubernetes/ui-rc.yaml#L36).
|
||||||
- **auth_mode**: The authentication mode of Harbor. By default it is *db_auth*, i.e. the credentials are stored in a database. Please set it to *ldap_auth* if you want to verify user's credentials against an LDAP server. You can change the configuration [here](https://github.com/vmware/harbor/blob/master/Deploy/kubernetes/ui-rc.yaml#L40).
|
- **auth_mode**: The authentication mode of Harbor. By default it is *db_auth*, i.e. the credentials are stored in a database. Please set it to *ldap_auth* if you want to verify user's credentials against an LDAP server. You can change the configuration [here](https://github.com/vmware/harbor/blob/master/make/kubernetes/ui-rc.yaml#L40).
|
||||||
- **ldap_url**: The URL for LDAP endpoint, for example ldaps://ldap.mydomain.com. It is only used when **auth_mode** is set to *ldap_auth*. It could be changed [here](https://github.com/vmware/harbor/blob/master/Deploy/kubernetes/ui-rc.yaml#L42).
|
- **ldap_url**: The URL for LDAP endpoint, for example ldaps://ldap.mydomain.com. It is only used when **auth_mode** is set to *ldap_auth*. It could be changed [here](https://github.com/vmware/harbor/blob/master/make/kubernetes/ui-rc.yaml#L42).
|
||||||
- **ldap_basedn**: The basedn template for verifying the user's credentials against LDAP, for example uid=%s,ou=people,dc=mydomain,dc=com. It is only used when **auth_mode** is set to *ldap_auth*. It could be changed [here](https://github.com/vmware/harbor/blob/master/Deploy/kubernetes/ui-rc.yaml#L44).
|
- **ldap_basedn**: The basedn template for verifying the user's credentials against LDAP, for example uid=%s,ou=people,dc=mydomain,dc=com. It is only used when **auth_mode** is set to *ldap_auth*. It could be changed [here](https://github.com/vmware/harbor/blob/master/make/kubernetes/ui-rc.yaml#L44).
|
||||||
- **db_password**: The password of root user of mySQL database. Change this password for any production use. You need to change both [here](https://github.com/vmware/harbor/blob/master/Deploy/kubernetes/ui-rc.yaml#L28) and [here](https://github.com/vmware/harbor/blob/master/Deploy/harbor.cfg#L32) to make the change. Please note, you need to change the ```harbor.cfg``` before building the docker images.
|
- **db_password**: The password of root user of mySQL database. Change this password for any production use. You need to change both [here](https://github.com/vmware/harbor/blob/master/make/kubernetes/ui-rc.yaml#L28) and [here](https://github.com/vmware/harbor/blob/master/make/harbor.cfg#L32) to make the change. Please note, you need to change the ```harbor.cfg``` before building the docker images.
|
||||||
|
|
||||||
Finally you can start the jobs by running:
|
Finally you can start the jobs by running:
|
||||||
```
|
```
|
||||||
kubectl create -f Deploy/kubernetes
|
kubectl create -f make/kubernetes
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ When upgrading your existing Habor instance to a newer version, you may need to
|
|||||||
1. Log in to the machine that Harbor runs on, stop and remove existing Harbor service if it is still running:
|
1. Log in to the machine that Harbor runs on, stop and remove existing Harbor service if it is still running:
|
||||||
|
|
||||||
```
|
```
|
||||||
cd Deploy/
|
cd make/
|
||||||
docker-compose down
|
docker-compose down
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -49,11 +49,11 @@ The directory **migration/** contains the tool for migration. The first step is
|
|||||||
docker run -ti --rm -v /data/database:/var/lib/mysql migrate-tool up head
|
docker run -ti --rm -v /data/database:/var/lib/mysql migrate-tool up head
|
||||||
```
|
```
|
||||||
|
|
||||||
8. Change to `Deploy/` directory, configure Harbor by modifying the file `harbor.cfg`, you may need to refer to the configuration files you've backed up during step 2. Refer to [Installation & Configuration Guide ](../docs/installation_guide.md) for more info.
|
8. Change to `make/` directory, configure Harbor by modifying the file `harbor.cfg`, you may need to refer to the configuration files you've backed up during step 2. Refer to [Installation & Configuration Guide ](../docs/installation_guide.md) for more info.
|
||||||
|
|
||||||
9. If HTTPS has been enabled for Harbor before, restore the `nginx.conf` and key/certificate files from the backup files in Step 2. Refer to [Configuring Harbor with HTTPS Access](../docs/configure_https.md) for more info.
|
9. If HTTPS has been enabled for Harbor before, restore the `nginx.conf` and key/certificate files from the backup files in Step 2. Refer to [Configuring Harbor with HTTPS Access](../docs/configure_https.md) for more info.
|
||||||
|
|
||||||
10. Under the directory `Deploy/`, run the `./prepare` script to generate necessary config files.
|
10. Under the directory `make/`, run the `./prepare` script to generate necessary config files.
|
||||||
|
|
||||||
11. Rebuild Harbor and restart the registry service
|
11. Rebuild Harbor and restart the registry service
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ For any reason, if you want to roll back to the previous version of Harbor, foll
|
|||||||
1. Stop and remove the current Harbor service if it is still running.
|
1. Stop and remove the current Harbor service if it is still running.
|
||||||
|
|
||||||
```
|
```
|
||||||
cd Deploy/
|
cd make/
|
||||||
docker-compose down
|
docker-compose down
|
||||||
```
|
```
|
||||||
2. Restore database from backup file in `/path/to/backup` .
|
2. Restore database from backup file in `/path/to/backup` .
|
||||||
@ -88,7 +88,7 @@ For any reason, if you want to roll back to the previous version of Harbor, foll
|
|||||||
|
|
||||||
5. Restart Harbor service using the previous configuration.
|
5. Restart Harbor service using the previous configuration.
|
||||||
```sh
|
```sh
|
||||||
cd Deploy/
|
cd make/
|
||||||
docker-compose up --build -d
|
docker-compose up --build -d
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@ rm -f *.tar.gz
|
|||||||
echo "Downloading Swagger UI release package..."
|
echo "Downloading Swagger UI release package..."
|
||||||
wget https://github.com/swagger-api/swagger-ui/archive/v2.1.4.tar.gz -O swagger.tar.gz
|
wget https://github.com/swagger-api/swagger-ui/archive/v2.1.4.tar.gz -O swagger.tar.gz
|
||||||
echo "Untarring Swagger UI package to the static file path..."
|
echo "Untarring Swagger UI package to the static file path..."
|
||||||
tar -C ../static/vendors -zxf swagger.tar.gz swagger-ui-2.1.4/dist
|
tar -C ../src/ui/static/vendors -zxf swagger.tar.gz swagger-ui-2.1.4/dist
|
||||||
echo "Executing some processes..."
|
echo "Executing some processes..."
|
||||||
sed -i.bak 's/http:\/\/petstore\.swagger\.io\/v2\/swagger\.json/'$SCHEME':\/\/'$SERVER_IP'\/static\/resources\/yaml\/swagger\.yaml/g' \
|
sed -i.bak 's/http:\/\/petstore\.swagger\.io\/v2\/swagger\.json/'$SCHEME':\/\/'$SERVER_IP'\/static\/resources\/yaml\/swagger\.yaml/g' \
|
||||||
../static/vendors/swagger-ui-2.1.4/dist/index.html
|
../src/ui/static/vendors/swagger-ui-2.1.4/dist/index.html
|
||||||
sed -i.bak '/jsonEditor: false,/a\ validatorUrl: null,' ../static/vendors/swagger-ui-2.1.4/dist/index.html
|
sed -i.bak '/jsonEditor: false,/a\ validatorUrl: null,' ../src/ui/static/vendors/swagger-ui-2.1.4/dist/index.html
|
||||||
mkdir -p ../static/resources/yaml
|
mkdir -p ../src/ui/static/resources/yaml
|
||||||
cp swagger.yaml ../static/resources/yaml
|
cp swagger.yaml ../src/ui/static/resources/yaml
|
||||||
sed -i.bak 's/host: localhost/host: '$SERVER_IP'/g' ../static/resources/yaml/swagger.yaml
|
sed -i.bak 's/host: localhost/host: '$SERVER_IP'/g' ../src/ui/static/resources/yaml/swagger.yaml
|
||||||
sed -i.bak 's/ \- http$/ \- '$SCHEME'/g' ../static/resources/yaml/swagger.yaml
|
sed -i.bak 's/ \- http$/ \- '$SCHEME'/g' ../src/ui/static/resources/yaml/swagger.yaml
|
||||||
echo "Finish preparation for the Swagger UI."
|
echo "Finish preparation for the Swagger UI."
|
||||||
|
150
make/checkenv.sh
Executable file
150
make/checkenv.sh
Executable file
@ -0,0 +1,150 @@
|
|||||||
|
#/bin/bash
|
||||||
|
|
||||||
|
#docker version: 1.11.2
|
||||||
|
#docker-compose version: 1.7.1
|
||||||
|
#Harbor version: 0.4.5+
|
||||||
|
set +e
|
||||||
|
set -o noglob
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set Colors
|
||||||
|
#
|
||||||
|
|
||||||
|
bold=$(tput bold)
|
||||||
|
underline=$(tput sgr 0 1)
|
||||||
|
reset=$(tput sgr0)
|
||||||
|
|
||||||
|
red=$(tput setaf 1)
|
||||||
|
green=$(tput setaf 76)
|
||||||
|
white=$(tput setaf 7)
|
||||||
|
tan=$(tput setaf 202)
|
||||||
|
blue=$(tput setaf 25)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Headers and Logging
|
||||||
|
#
|
||||||
|
|
||||||
|
underline() { printf "${underline}${bold}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
debug() { printf "${white}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
info() { printf "${white}➜ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
success() { printf "${green}✔ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
error() { printf "${red}✖ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
warn() { printf "${tan}➜ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
bold() { printf "${bold}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
usage=$'Checking environment for harbor build and install. Include golang, docker and docker-compose.'
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
--help)
|
||||||
|
note "$usage"
|
||||||
|
exit 0;;
|
||||||
|
*)
|
||||||
|
note "$usage"
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
shift || true
|
||||||
|
done
|
||||||
|
|
||||||
|
function check_golang {
|
||||||
|
if ! go version &> /dev/null
|
||||||
|
then
|
||||||
|
warn "No golang package in your enviroment. You should use golang docker image build binary."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# docker has been installed and check its version
|
||||||
|
if [[ $(go version) =~ (([0-9]+).([0-9]+).([0-9]+)) ]]
|
||||||
|
then
|
||||||
|
golang_version=${BASH_REMATCH[1]}
|
||||||
|
golang_version_part1=${BASH_REMATCH[2]}
|
||||||
|
golang_version_part2=${BASH_REMATCH[3]}
|
||||||
|
|
||||||
|
# the version of golang does not meet the requirement
|
||||||
|
if [ "$golang_version_part1" -lt 1 ] || ([ "$golang_version_part1" -eq 1 ] && [ "$golang_version_part2" -lt 6 ])
|
||||||
|
then
|
||||||
|
warn "Better to upgrade golang package to 1.6.0+ or use golang docker image build binary."
|
||||||
|
return
|
||||||
|
else
|
||||||
|
note "golang version: $golang_version"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Failed to parse golang version."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_docker {
|
||||||
|
if ! docker --version &> /dev/null
|
||||||
|
then
|
||||||
|
error "Need to install docker(1.10.0+) first and run this script again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# docker has been installed and check its version
|
||||||
|
if [[ $(docker --version) =~ (([0-9]+).([0-9]+).([0-9]+)) ]]
|
||||||
|
then
|
||||||
|
docker_version=${BASH_REMATCH[1]}
|
||||||
|
docker_version_part1=${BASH_REMATCH[2]}
|
||||||
|
docker_version_part2=${BASH_REMATCH[3]}
|
||||||
|
|
||||||
|
# the version of docker does not meet the requirement
|
||||||
|
if [ "$docker_version_part1" -lt 1 ] || ([ "$docker_version_part1" -eq 1 ] && [ "$docker_version_part2" -lt 10 ])
|
||||||
|
then
|
||||||
|
error "Need to upgrade docker package to 1.10.0+."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
note "docker version: $docker_version"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
error "Failed to parse docker version."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_dockercompose {
|
||||||
|
if ! docker-compose --version &> /dev/null
|
||||||
|
then
|
||||||
|
error "Need to install docker-compose(1.7.1+) by yourself first and run this script again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# docker-compose has been installed, check its version
|
||||||
|
if [[ $(docker-compose --version) =~ (([0-9]+).([0-9]+).([0-9]+)) ]]
|
||||||
|
then
|
||||||
|
docker_compose_version=${BASH_REMATCH[1]}
|
||||||
|
docker_compose_version_part1=${BASH_REMATCH[2]}
|
||||||
|
docker_compose_version_part2=${BASH_REMATCH[3]}
|
||||||
|
|
||||||
|
# the version of docker-compose does not meet the requirement
|
||||||
|
if [ "$docker_compose_version_part1" -lt 1 ] || ([ "$docker_compose_version_part1" -eq 1 ] && [ "$docker_compose_version_part2" -lt 6 ])
|
||||||
|
then
|
||||||
|
error "Need to upgrade docker-compose package to 1.7.1+."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
note "docker-compose version: $docker_compose_version"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
error "Failed to parse docker-compose version."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_golang
|
||||||
|
check_docker
|
||||||
|
check_dockercompose
|
@ -1,7 +1,9 @@
|
|||||||
version: '2'
|
version: '2'
|
||||||
services:
|
services:
|
||||||
log:
|
log:
|
||||||
build: ./log/
|
build:
|
||||||
|
context: ../../
|
||||||
|
dockerfile: make/ubuntu/log/Dockerfile
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- /var/log/harbor/:/var/log/docker/
|
- /var/log/harbor/:/var/log/docker/
|
||||||
@ -12,7 +14,7 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- /data/registry:/storage
|
- /data/registry:/storage
|
||||||
- ./config/registry/:/etc/registry/
|
- ../common/config/registry/:/etc/registry/
|
||||||
environment:
|
environment:
|
||||||
- GODEBUG=netdns=cgo
|
- GODEBUG=netdns=cgo
|
||||||
command:
|
command:
|
||||||
@ -25,12 +27,12 @@ services:
|
|||||||
syslog-address: "tcp://127.0.0.1:1514"
|
syslog-address: "tcp://127.0.0.1:1514"
|
||||||
tag: "registry"
|
tag: "registry"
|
||||||
mysql:
|
mysql:
|
||||||
build: ./db/
|
build: ../common/db/
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- /data/database:/var/lib/mysql
|
- /data/database:/var/lib/mysql
|
||||||
env_file:
|
env_file:
|
||||||
- ./config/db/env
|
- ../common/config/db/env
|
||||||
depends_on:
|
depends_on:
|
||||||
- log
|
- log
|
||||||
logging:
|
logging:
|
||||||
@ -40,14 +42,14 @@ services:
|
|||||||
tag: "mysql"
|
tag: "mysql"
|
||||||
ui:
|
ui:
|
||||||
build:
|
build:
|
||||||
context: ../
|
context: ../../
|
||||||
dockerfile: Deploy/ui/Dockerfile
|
dockerfile: make/dev/ui/Dockerfile
|
||||||
env_file:
|
env_file:
|
||||||
- ./config/ui/env
|
- ../common/config/ui/env
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ./config/ui/app.conf:/etc/ui/app.conf
|
- ../common/config/ui/app.conf:/etc/ui/app.conf
|
||||||
- ./config/ui/private_key.pem:/etc/ui/private_key.pem
|
- ../common/config/ui/private_key.pem:/etc/ui/private_key.pem
|
||||||
depends_on:
|
depends_on:
|
||||||
- log
|
- log
|
||||||
logging:
|
logging:
|
||||||
@ -57,14 +59,14 @@ services:
|
|||||||
tag: "ui"
|
tag: "ui"
|
||||||
jobservice:
|
jobservice:
|
||||||
build:
|
build:
|
||||||
context: ../
|
context: ../../
|
||||||
dockerfile: Deploy/jobservice/Dockerfile
|
dockerfile: make/dev/jobservice/Dockerfile
|
||||||
env_file:
|
env_file:
|
||||||
- ./config/jobservice/env
|
- ../common/config/jobservice/env
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- /data/job_logs:/var/log/jobs
|
- /data/job_logs:/var/log/jobs
|
||||||
- ./config/jobservice/app.conf:/etc/jobservice/app.conf
|
- ../common/config/jobservice/app.conf:/etc/jobservice/app.conf
|
||||||
depends_on:
|
depends_on:
|
||||||
- ui
|
- ui
|
||||||
logging:
|
logging:
|
||||||
@ -76,7 +78,7 @@ services:
|
|||||||
image: library/nginx:1.9
|
image: library/nginx:1.9
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ./config/nginx:/etc/nginx
|
- ../common/config/nginx:/etc/nginx
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
- 443:443
|
- 443:443
|
@ -8,7 +8,7 @@ RUN apt-get update \
|
|||||||
|
|
||||||
COPY . /go/src/github.com/vmware/harbor
|
COPY . /go/src/github.com/vmware/harbor
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/vmware/harbor/jobservice
|
WORKDIR /go/src/github.com/vmware/harbor/src/jobservice
|
||||||
|
|
||||||
RUN go build -v -a -o /go/bin/harbor_jobservice \
|
RUN go build -v -a -o /go/bin/harbor_jobservice \
|
||||||
&& chmod u+x /go/bin/harbor_jobservice
|
&& chmod u+x /go/bin/harbor_jobservice
|
BIN
make/dev/jobservice/harbor_jobservice
Executable file
BIN
make/dev/jobservice/harbor_jobservice
Executable file
Binary file not shown.
@ -6,8 +6,8 @@ RUN apt-get update \
|
|||||||
&& apt-get install -y libldap2-dev \
|
&& apt-get install -y libldap2-dev \
|
||||||
&& rm -r /var/lib/apt/lists/*
|
&& rm -r /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY . /go/src/github.com/vmware/harbor
|
COPY src/. /go/src/github.com/vmware/harbor/src
|
||||||
WORKDIR /go/src/github.com/vmware/harbor/ui
|
WORKDIR /go/src/github.com/vmware/harbor/src/ui
|
||||||
|
|
||||||
RUN go build -v -a -o /go/bin/harbor_ui
|
RUN go build -v -a -o /go/bin/harbor_ui
|
||||||
|
|
||||||
@ -15,15 +15,15 @@ ENV MYSQL_USR root \
|
|||||||
MYSQL_PWD root \
|
MYSQL_PWD root \
|
||||||
REGISTRY_URL localhost:5000
|
REGISTRY_URL localhost:5000
|
||||||
|
|
||||||
COPY views /go/bin/views
|
COPY src/ui/views /go/bin/views
|
||||||
COPY static /go/bin/static
|
COPY src/ui/static /go/bin/static
|
||||||
COPY favicon.ico /go/bin/favicon.ico
|
COPY src/favicon.ico /go/bin/favicon.ico
|
||||||
COPY Deploy/jsminify.sh /tmp/jsminify.sh
|
COPY make/jsminify.sh /tmp/jsminify.sh
|
||||||
|
|
||||||
RUN chmod u+x /go/bin/harbor_ui \
|
RUN chmod u+x /go/bin/harbor_ui \
|
||||||
&& sed -i 's/TLS_CACERT/#TLS_CAERT/g' /etc/ldap/ldap.conf \
|
&& sed -i 's/TLS_CACERT/#TLS_CAERT/g' /etc/ldap/ldap.conf \
|
||||||
&& sed -i '$a\TLS_REQCERT allow' /etc/ldap/ldap.conf \
|
&& sed -i '$a\TLS_REQCERT allow' /etc/ldap/ldap.conf \
|
||||||
&& /tmp/jsminify.sh /go/bin/views/sections/script-include.htm /go/bin/static/resources/js/harbor.app.min.js
|
&& /tmp/jsminify.sh /go/bin/views/sections/script-include.htm /go/bin/static/resources/js/harbor.app.min.js /go/bin/
|
||||||
|
|
||||||
WORKDIR /go/bin/
|
WORKDIR /go/bin/
|
||||||
ENTRYPOINT ["/go/bin/harbor_ui"]
|
ENTRYPOINT ["/go/bin/harbor_ui"]
|
BIN
make/dev/ui/harbor_ui
Executable file
BIN
make/dev/ui/harbor_ui
Executable file
Binary file not shown.
@ -1,7 +1,8 @@
|
|||||||
version: '2'
|
version: '2'
|
||||||
services:
|
services:
|
||||||
log:
|
log:
|
||||||
image: harbor_log_photon
|
image: vmware/harbor-log
|
||||||
|
container_name: harbor-log
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- /var/log/harbor/:/var/log/docker/
|
- /var/log/harbor/:/var/log/docker/
|
||||||
@ -9,10 +10,11 @@ services:
|
|||||||
- 1514:514
|
- 1514:514
|
||||||
registry:
|
registry:
|
||||||
image: library/registry:2.5.0
|
image: library/registry:2.5.0
|
||||||
|
container_name: registry
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- /data/registry:/storage
|
- /data/registry:/storage
|
||||||
- ./config/registry/:/etc/registry/
|
- ./common/config/registry/:/etc/registry/
|
||||||
environment:
|
environment:
|
||||||
- GODEBUG=netdns=cgo
|
- GODEBUG=netdns=cgo
|
||||||
command:
|
command:
|
||||||
@ -25,12 +27,13 @@ services:
|
|||||||
syslog-address: "tcp://127.0.0.1:1514"
|
syslog-address: "tcp://127.0.0.1:1514"
|
||||||
tag: "registry"
|
tag: "registry"
|
||||||
mysql:
|
mysql:
|
||||||
build: ./db/
|
image: vmware/harbor-db
|
||||||
|
container_name: harbor-db
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- /data/database:/var/lib/mysql
|
- /data/database:/var/lib/mysql
|
||||||
env_file:
|
env_file:
|
||||||
- ./config/db/env
|
- ./common/config/db/env
|
||||||
depends_on:
|
depends_on:
|
||||||
- log
|
- log
|
||||||
logging:
|
logging:
|
||||||
@ -39,13 +42,14 @@ services:
|
|||||||
syslog-address: "tcp://127.0.0.1:1514"
|
syslog-address: "tcp://127.0.0.1:1514"
|
||||||
tag: "mysql"
|
tag: "mysql"
|
||||||
ui:
|
ui:
|
||||||
image: harbor_ui_photon
|
image: vmware/harbor-ui
|
||||||
|
container_name: harbor-ui
|
||||||
env_file:
|
env_file:
|
||||||
- ./config/ui/env
|
- ./common/config/ui/env
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ./config/ui/app.conf:/etc/ui/app.conf
|
- ./common/config/ui/app.conf:/etc/ui/app.conf
|
||||||
- ./config/ui/private_key.pem:/etc/ui/private_key.pem
|
- ./common/config/ui/private_key.pem:/etc/ui/private_key.pem
|
||||||
depends_on:
|
depends_on:
|
||||||
- log
|
- log
|
||||||
logging:
|
logging:
|
||||||
@ -54,13 +58,14 @@ services:
|
|||||||
syslog-address: "tcp://127.0.0.1:1514"
|
syslog-address: "tcp://127.0.0.1:1514"
|
||||||
tag: "ui"
|
tag: "ui"
|
||||||
jobservice:
|
jobservice:
|
||||||
image: harbor_jobservice_photon
|
image: vmware/harbor-jobservice
|
||||||
|
container_name: harbor-jobservice
|
||||||
env_file:
|
env_file:
|
||||||
- ./config/jobservice/env
|
- ./common/config/jobservice/env
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- /data/job_logs:/var/log/jobs
|
- /data/job_logs:/var/log/jobs
|
||||||
- ./config/jobservice/app.conf:/etc/jobservice/app.conf
|
- ./common/config/jobservice/app.conf:/etc/jobservice/app.conf
|
||||||
depends_on:
|
depends_on:
|
||||||
- ui
|
- ui
|
||||||
logging:
|
logging:
|
||||||
@ -69,10 +74,11 @@ services:
|
|||||||
syslog-address: "tcp://127.0.0.1:1514"
|
syslog-address: "tcp://127.0.0.1:1514"
|
||||||
tag: "jobservice"
|
tag: "jobservice"
|
||||||
proxy:
|
proxy:
|
||||||
image: library/nginx:1.9.0
|
image: nginx:1.9.0
|
||||||
|
container_name: nginx
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ./config/nginx:/etc/nginx
|
- ./common/config/nginx:/etc/nginx
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
- 443:443
|
- 443:443
|
181
make/install.sh
Executable file
181
make/install.sh
Executable file
@ -0,0 +1,181 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#docker version: 1.11.2
|
||||||
|
#docker-compose version: 1.7.1
|
||||||
|
#Harbor version: 0.4.0
|
||||||
|
|
||||||
|
set +e
|
||||||
|
set -o noglob
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set Colors
|
||||||
|
#
|
||||||
|
|
||||||
|
bold=$(tput bold)
|
||||||
|
underline=$(tput sgr 0 1)
|
||||||
|
reset=$(tput sgr0)
|
||||||
|
|
||||||
|
red=$(tput setaf 1)
|
||||||
|
green=$(tput setaf 76)
|
||||||
|
white=$(tput setaf 7)
|
||||||
|
tan=$(tput setaf 202)
|
||||||
|
blue=$(tput setaf 25)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Headers and Logging
|
||||||
|
#
|
||||||
|
|
||||||
|
underline() { printf "${underline}${bold}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
debug() { printf "${white}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
info() { printf "${white}➜ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
success() { printf "${green}✔ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
error() { printf "${red}✖ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
warn() { printf "${tan}➜ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
bold() { printf "${bold}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
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.'
|
||||||
|
item=0
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
--help)
|
||||||
|
note "$usage"
|
||||||
|
exit 0;;
|
||||||
|
*)
|
||||||
|
note "$usage"
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
shift || true
|
||||||
|
done
|
||||||
|
|
||||||
|
workdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
cd $workdir
|
||||||
|
|
||||||
|
# The hostname in harbor.cfg has not been modified
|
||||||
|
if grep 'hostname = reg.mydomain.com' &> /dev/null harbor.cfg
|
||||||
|
then
|
||||||
|
warn "$usage"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
function check_docker {
|
||||||
|
if ! docker --version &> /dev/null
|
||||||
|
then
|
||||||
|
error "Need to install docker(1.10.0+) first and run this script again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# docker has been installed and check its version
|
||||||
|
if [[ $(docker --version) =~ (([0-9]+).([0-9]+).([0-9]+)) ]]
|
||||||
|
then
|
||||||
|
docker_version=${BASH_REMATCH[1]}
|
||||||
|
docker_version_part1=${BASH_REMATCH[2]}
|
||||||
|
docker_version_part2=${BASH_REMATCH[3]}
|
||||||
|
|
||||||
|
# the version of docker does not meet the requirement
|
||||||
|
if [ "$docker_version_part1" -lt 1 ] || ([ "$docker_version_part1" -eq 1 ] && [ "$docker_version_part2" -lt 10 ])
|
||||||
|
then
|
||||||
|
error "Need to upgrade docker package to 1.10.0+."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
note "docker version: $docker_version"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
error "Failed to parse docker version."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_dockercompose {
|
||||||
|
if ! docker-compose --version &> /dev/null
|
||||||
|
then
|
||||||
|
error "Need to install docker-compose(1.7.1+) by yourself first and run this script again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# docker-compose has been installed, check its version
|
||||||
|
if [[ $(docker-compose --version) =~ (([0-9]+).([0-9]+).([0-9]+)) ]]
|
||||||
|
then
|
||||||
|
docker_compose_version=${BASH_REMATCH[1]}
|
||||||
|
docker_compose_version_part1=${BASH_REMATCH[2]}
|
||||||
|
docker_compose_version_part2=${BASH_REMATCH[3]}
|
||||||
|
|
||||||
|
# the version of docker-compose does not meet the requirement
|
||||||
|
if [ "$docker_compose_version_part1" -lt 1 ] || ([ "$docker_compose_version_part1" -eq 1 ] && [ "$docker_compose_version_part2" -lt 6 ])
|
||||||
|
then
|
||||||
|
error "Need to upgrade docker-compose package to 1.7.1+."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
note "docker-compose version: $docker_compose_version"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
error "Failed to parse docker-compose version."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 "[Step $item]: checking installation environment ..."; let item+=1
|
||||||
|
check_docker
|
||||||
|
check_dockercompose
|
||||||
|
|
||||||
|
if [ -f harbor*.tgz ]
|
||||||
|
then
|
||||||
|
h2 "[Step $item]: loading Harbor images ..."; let item+=1
|
||||||
|
docker load -i ./harbor*.tgz
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
h2 "[Step $item]: preparing environment ..."; let item+=1
|
||||||
|
if [ -n "$host" ]
|
||||||
|
then
|
||||||
|
sed "s/^hostname = .*/hostname = $host/g" -i ./harbor.cfg
|
||||||
|
fi
|
||||||
|
./prepare
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
h2 "[Step $item]: starting Harbor ..."
|
||||||
|
docker-compose -f docker-compose*.yml up -d
|
||||||
|
|
||||||
|
protocol=http
|
||||||
|
hostname=reg.mydomain.com
|
||||||
|
|
||||||
|
if [[ $(cat ./harbor.cfg) =~ ui_url_protocol[[:blank:]]*=[[:blank:]]*(https?) ]]
|
||||||
|
then
|
||||||
|
protocol=${BASH_REMATCH[1]}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $(grep 'hostname[[:blank:]]*=' ./harbor.cfg) =~ hostname[[:blank:]]*=[[:blank:]]*(.*) ]]
|
||||||
|
then
|
||||||
|
hostname=${BASH_REMATCH[1]}
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
success $"----Harbor has been installed and started successfully.----
|
||||||
|
|
||||||
|
Now you should be able to visit the admin portal at ${protocol}://${hostname}.
|
||||||
|
For more details, please visit https://github.com/vmware/harbor .
|
||||||
|
"
|
74
make/photon/Makefile
Normal file
74
make/photon/Makefile
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# Makefile for a harbor project
|
||||||
|
#
|
||||||
|
# Targets:
|
||||||
|
#
|
||||||
|
# build: build harbor photon images
|
||||||
|
# clean: clean ui and jobservice harbor images
|
||||||
|
|
||||||
|
# common
|
||||||
|
SHELL := /bin/bash
|
||||||
|
BUILDPATH=$(CURDIR)
|
||||||
|
DEPLOYPATH=$(BUILDPATH)/make
|
||||||
|
DEPLOYDEVPATH=$(DEPLOYPATH)/dev
|
||||||
|
SRCPATH=./src
|
||||||
|
TOOLSPATH=$(BUILDPATH)/tools
|
||||||
|
CHECKENVCMD=checkenv.sh
|
||||||
|
|
||||||
|
# docker parameters
|
||||||
|
DOCKERCMD=$(shell which docker)
|
||||||
|
DOCKERBUILD=$(DOCKERCMD) build
|
||||||
|
DOCKERRMIMAGE=$(DOCKERCMD) rmi
|
||||||
|
DOCKERIMASES=$(DOCKERCMD) images
|
||||||
|
|
||||||
|
# binary
|
||||||
|
UISOURCECODE=$(SRCPATH)/ui
|
||||||
|
UIBINARYPATH=$(DEPLOYDEVPATH)/ui
|
||||||
|
UIBINARYNAME=harbor_ui
|
||||||
|
JOBSERVICESOURCECODE=$(SRCPATH)/jobservice
|
||||||
|
JOBSERVICEBINARYPATH=$(DEPLOYDEVPATH)/jobservice
|
||||||
|
JOBSERVICEBINARYNAME=harbor_jobservice
|
||||||
|
|
||||||
|
# photon dockerfile
|
||||||
|
DOCKERFILEPATH=$(DEPLOYPATH)/photon
|
||||||
|
DOCKERFILEPATH_UI=$(DOCKERFILEPATH)/ui
|
||||||
|
DOCKERFILENAME_UI=Dockerfile
|
||||||
|
DOCKERIMAGENAME_UI=vmware/harbor-ui
|
||||||
|
DOCKERFILEPATH_JOBSERVICE=$(DOCKERFILEPATH)/jobservice
|
||||||
|
DOCKERFILENAME_JOBSERVICE=Dockerfile
|
||||||
|
DOCKERIMAGENAME_JOBSERVICE=vmware/harbor-jobservice
|
||||||
|
DOCKERFILEPATH_LOG=$(DOCKERFILEPATH)/log
|
||||||
|
DOCKERFILENAME_LOG=Dockerfile
|
||||||
|
DOCKERIMAGENAME_LOG=vmware/harbor-log
|
||||||
|
|
||||||
|
# version prepare
|
||||||
|
VERSIONFILEPATH=$(SRCPATH)/views/sections
|
||||||
|
VERSIONFILENAME=header-content.htm
|
||||||
|
GITCMD=$(shell which git)
|
||||||
|
GITTAG=$(GITCMD) describe --tags
|
||||||
|
VERSIONTAG=$(shell $(GITTAG))
|
||||||
|
|
||||||
|
check_environment:
|
||||||
|
@$(TOOLSPATH)/$(CHECKENVCMD)
|
||||||
|
|
||||||
|
build:
|
||||||
|
@echo "building ui container for photon..."
|
||||||
|
$(DOCKERBUILD) -f $(DOCKERFILEPATH_UI)/$(DOCKERFILENAME_UI) -t $(DOCKERIMAGENAME_UI):$(VERSIONTAG) .
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
@echo "building jobservice container for photon..."
|
||||||
|
$(DOCKERBUILD) -f $(DOCKERFILEPATH_JOBSERVICE)/$(DOCKERFILENAME_JOBSERVICE) -t $(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG) .
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
@echo "building log container for photon..."
|
||||||
|
$(DOCKERBUILD) -f $(DOCKERFILEPATH_LOG)/$(DOCKERFILENAME_LOG) -t $(DOCKERIMAGENAME_LOG):$(VERSIONTAG) .
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
cleanimage:
|
||||||
|
@echo "cleaning image for photon..."
|
||||||
|
- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_UI):$(VERSIONTAG)
|
||||||
|
- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG)
|
||||||
|
- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_LOG):$(VERSIONTAG)
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean: cleanimage
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
FROM library/photon:latest
|
FROM library/photon:latest
|
||||||
|
|
||||||
RUN mkdir /harbor/
|
RUN mkdir /harbor/
|
||||||
COPY ./Deploy/jobservice/harbor_jobservice /harbor/
|
COPY ./make/dev/jobservice/harbor_jobservice /harbor/
|
||||||
|
|
||||||
RUN chmod u+x /harbor/harbor_jobservice
|
RUN chmod u+x /harbor/harbor_jobservice
|
||||||
WORKDIR /harbor/
|
WORKDIR /harbor/
|
@ -8,15 +8,15 @@ RUN tdnf install -y cronie rsyslog logrotate shadow\
|
|||||||
&& groupadd syslog \
|
&& groupadd syslog \
|
||||||
&& useradd -g syslog syslog
|
&& useradd -g syslog syslog
|
||||||
|
|
||||||
ADD rsyslog.conf /etc/rsyslog.conf
|
ADD make/common/log/rsyslog.conf /etc/rsyslog.conf
|
||||||
|
|
||||||
COPY logrotate.conf.photon /etc/logrotate.conf
|
COPY make/photon/log/logrotate.conf.photon /etc/logrotate.conf
|
||||||
|
|
||||||
# logrotate configuration file for docker
|
# logrotate configuration file for docker
|
||||||
ADD logrotate_docker.conf /etc/logrotate.d/
|
ADD make/common/log/logrotate_docker.conf /etc/logrotate.d/
|
||||||
|
|
||||||
# rsyslog configuration file for docker
|
# rsyslog configuration file for docker
|
||||||
ADD rsyslog_docker.conf /etc/rsyslog.d/
|
ADD make/common/log/rsyslog_docker.conf /etc/rsyslog.d/
|
||||||
|
|
||||||
|
|
||||||
VOLUME /var/log/docker/
|
VOLUME /var/log/docker/
|
@ -3,12 +3,12 @@ FROM library/photon:latest
|
|||||||
RUN mkdir /harbor/
|
RUN mkdir /harbor/
|
||||||
RUN tdnf install -y sed apr-util-ldap
|
RUN tdnf install -y sed apr-util-ldap
|
||||||
|
|
||||||
COPY ./Deploy/ui/harbor_ui /harbor/
|
COPY ./make/dev/ui/harbor_ui /harbor/
|
||||||
|
|
||||||
COPY ./views /harbor/views
|
COPY ./src/ui/views /harbor/views
|
||||||
COPY ./static /harbor/static
|
COPY ./src/ui/static /harbor/static
|
||||||
COPY ./favicon.ico /harbor/favicon.ico
|
COPY ./src/favicon.ico /harbor/favicon.ico
|
||||||
COPY ./Deploy/jsminify.sh /tmp/jsminify.sh
|
COPY ./make/jsminify.sh /tmp/jsminify.sh
|
||||||
|
|
||||||
RUN chmod u+x /harbor/harbor_ui \
|
RUN chmod u+x /harbor/harbor_ui \
|
||||||
&& tmp/jsminify.sh /harbor/views/sections/script-include.htm /harbor/static/resources/js/harbor.app.min.js /harbor/ \
|
&& tmp/jsminify.sh /harbor/views/sections/script-include.htm /harbor/static/resources/js/harbor.app.min.js /harbor/ \
|
@ -50,8 +50,12 @@ def get_secret_key(path):
|
|||||||
print("generated and saved secret key")
|
print("generated and saved secret key")
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
base_dir = os.path.dirname(__file__)
|
||||||
|
config_dir = os.path.join(base_dir, "common/config")
|
||||||
|
templates_dir = os.path.join(base_dir, "common/templates")
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-conf', dest='cfgfile', default='harbor.cfg',type=str,help="the path of Harbor configuration file")
|
parser.add_argument('-conf', dest='cfgfile', default=base_dir+'/harbor.cfg',type=str,help="the path of Harbor configuration file")
|
||||||
parser.add_argument('--data-volume', dest='data_volume', default='/data/',type=str,help="the path of Harbor data volume, which is set in template of docker-compose.")
|
parser.add_argument('--data-volume', dest='data_volume', default='/data/',type=str,help="the path of Harbor data volume, which is set in template of docker-compose.")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -116,10 +120,6 @@ secret_key = get_secret_key(args.data_volume)
|
|||||||
|
|
||||||
ui_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
|
ui_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
|
||||||
|
|
||||||
base_dir = os.path.dirname(__file__)
|
|
||||||
config_dir = os.path.join(base_dir, "config")
|
|
||||||
templates_dir = os.path.join(base_dir, "templates")
|
|
||||||
|
|
||||||
ui_config_dir = os.path.join(config_dir,"ui")
|
ui_config_dir = os.path.join(config_dir,"ui")
|
||||||
if not os.path.exists(ui_config_dir):
|
if not os.path.exists(ui_config_dir):
|
||||||
os.makedirs(os.path.join(config_dir, "ui"))
|
os.makedirs(os.path.join(config_dir, "ui"))
|
139
make/pushimage.sh
Executable file
139
make/pushimage.sh
Executable file
@ -0,0 +1,139 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set +e
|
||||||
|
set -o noglob
|
||||||
|
|
||||||
|
echo "This shell will push specific image to registry server."
|
||||||
|
echo "Usage: #./pushimage [imgae tag] [registry username] [registry password] [registry server]"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set Colors
|
||||||
|
#
|
||||||
|
|
||||||
|
bold=$(tput bold)
|
||||||
|
underline=$(tput sgr 0 1)
|
||||||
|
reset=$(tput sgr0)
|
||||||
|
|
||||||
|
red=$(tput setaf 1)
|
||||||
|
green=$(tput setaf 76)
|
||||||
|
white=$(tput setaf 7)
|
||||||
|
tan=$(tput setaf 202)
|
||||||
|
blue=$(tput setaf 25)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Headers and Logging
|
||||||
|
#
|
||||||
|
|
||||||
|
underline() { printf "${underline}${bold}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
debug() { printf "${white}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
info() { printf "${white}➜ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
success() { printf "${green}✔ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
error() { printf "${red}✖ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
warn() { printf "${tan}➜ %s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
bold() { printf "${bold}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type_exists() {
|
||||||
|
if [ $(type -P $1) ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check variables
|
||||||
|
if [ -z $1 ]; then
|
||||||
|
error "Please set the 'image' variable"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $2 ]; then
|
||||||
|
error "Please set the 'username' variable"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $3 ]; then
|
||||||
|
error "Please set the 'password' variable"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $4 ]; then
|
||||||
|
info "Using default registry server (dockerhub)."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Check Docker is installed
|
||||||
|
if ! type_exists 'docker'; then
|
||||||
|
error "Docker is not installed."
|
||||||
|
info "Please install docker package."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
IMAGE="$1"
|
||||||
|
USERNAME="$2"
|
||||||
|
PASSWORD="$3"
|
||||||
|
REGISTRY="$4"
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# ----- Pushing image(s) -----
|
||||||
|
# see documentation :
|
||||||
|
# - https://docs.docker.com/reference/commandline/cli/#login
|
||||||
|
# - https://docs.docker.com/reference/commandline/cli/#push
|
||||||
|
# - 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 $4"
|
||||||
|
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"
|
||||||
|
|
||||||
|
DOCKER_PUSH="docker push $IMAGE"
|
||||||
|
info "$DOCKER_PUSH"
|
||||||
|
DOCKER_PUSH_OUTPUT=$($DOCKER_PUSH)
|
||||||
|
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
warn $DOCKER_PUSH_OUTPUT
|
||||||
|
error "Pushing image $IMAGE failed";
|
||||||
|
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
|
74
make/ubuntu/Makefile
Normal file
74
make/ubuntu/Makefile
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# Makefile for a harbor project
|
||||||
|
#
|
||||||
|
# Targets:
|
||||||
|
#
|
||||||
|
# build: build harbor ubuntu images
|
||||||
|
# clean: clean ui and jobservice harbor images
|
||||||
|
|
||||||
|
# common
|
||||||
|
SHELL := /bin/bash
|
||||||
|
BUILDPATH=$(CURDIR)
|
||||||
|
DEPLOYPATH=$(BUILDPATH)/make
|
||||||
|
DEPLOYDEVPATH=$(DEPLOYPATH)/dev
|
||||||
|
SRCPATH=./src
|
||||||
|
TOOLSPATH=$(BUILDPATH)/tools
|
||||||
|
CHECKENVCMD=checkenv.sh
|
||||||
|
|
||||||
|
# docker parameters
|
||||||
|
DOCKERCMD=$(shell which docker)
|
||||||
|
DOCKERBUILD=$(DOCKERCMD) build
|
||||||
|
DOCKERRMIMAGE=$(DOCKERCMD) rmi
|
||||||
|
DOCKERIMASES=$(DOCKERCMD) images
|
||||||
|
|
||||||
|
# binary
|
||||||
|
UISOURCECODE=$(SRCPATH)/ui
|
||||||
|
UIBINARYPATH=$(DEPLOYDEVPATH)/ui
|
||||||
|
UIBINARYNAME=harbor_ui
|
||||||
|
JOBSERVICESOURCECODE=$(SRCPATH)/jobservice
|
||||||
|
JOBSERVICEBINARYPATH=$(DEPLOYDEVPATH)/jobservice
|
||||||
|
JOBSERVICEBINARYNAME=harbor_jobservice
|
||||||
|
|
||||||
|
# ubuntu dockerfile
|
||||||
|
DOCKERFILEPATH=$(DEPLOYPATH)/ubuntu
|
||||||
|
DOCKERFILEPATH_UI=$(DOCKERFILEPATH)/ui
|
||||||
|
DOCKERFILENAME_UI=Dockerfile
|
||||||
|
DOCKERIMAGENAME_UI=vmware/harbor-ui
|
||||||
|
DOCKERFILEPATH_JOBSERVICE=$(DOCKERFILEPATH)/jobservice
|
||||||
|
DOCKERFILENAME_JOBSERVICE=Dockerfile
|
||||||
|
DOCKERIMAGENAME_JOBSERVICE=vmware/harbor-jobservice
|
||||||
|
DOCKERFILEPATH_LOG=$(DOCKERFILEPATH)/log
|
||||||
|
DOCKERFILENAME_LOG=Dockerfile
|
||||||
|
DOCKERIMAGENAME_LOG=vmware/harbor-log
|
||||||
|
|
||||||
|
# version prepare
|
||||||
|
VERSIONFILEPATH=$(SRCPATH)/views/sections
|
||||||
|
VERSIONFILENAME=header-content.htm
|
||||||
|
GITCMD=$(shell which git)
|
||||||
|
GITTAG=$(GITCMD) describe --tags
|
||||||
|
VERSIONTAG=$(shell $(GITTAG))
|
||||||
|
|
||||||
|
check_environment:
|
||||||
|
@$(TOOLSPATH)/$(CHECKENVCMD)
|
||||||
|
|
||||||
|
build:
|
||||||
|
@echo "building ui container for ubuntu..."
|
||||||
|
$(DOCKERBUILD) -f $(DOCKERFILEPATH_UI)/$(DOCKERFILENAME_UI) -t $(DOCKERIMAGENAME_UI):$(VERSIONTAG) .
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
@echo "building jobservice container for ubuntu..."
|
||||||
|
$(DOCKERBUILD) -f $(DOCKERFILEPATH_JOBSERVICE)/$(DOCKERFILENAME_JOBSERVICE) -t $(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG) .
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
@echo "building log container for ubuntu..."
|
||||||
|
$(DOCKERBUILD) -f $(DOCKERFILEPATH_LOG)/$(DOCKERFILENAME_LOG) -t $(DOCKERIMAGENAME_LOG):$(VERSIONTAG) .
|
||||||
|
@echo "Done."
|
||||||
|
|
||||||
|
cleanimage:
|
||||||
|
@echo "cleaning image for ubuntu..."
|
||||||
|
- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_UI):$(VERSIONTAG)
|
||||||
|
- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG)
|
||||||
|
- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_LOG):$(VERSIONTAG)
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean: cleanimage
|
||||||
|
|
14
make/ubuntu/jobservice/Dockerfile
Normal file
14
make/ubuntu/jobservice/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
FROM golang:1.6.2
|
||||||
|
|
||||||
|
MAINTAINER jiangd@vmware.com
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y libldap2-dev \
|
||||||
|
&& rm -r /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN mkdir /harbor/
|
||||||
|
COPY ./make/dev/jobservice/harbor_jobservice /harbor/
|
||||||
|
|
||||||
|
RUN chmod u+x /harbor/harbor_jobservice
|
||||||
|
|
||||||
|
WORKDIR /harbor/
|
||||||
|
ENTRYPOINT ["/harbor/harbor_jobservice"]
|
@ -4,13 +4,13 @@ FROM library/ubuntu:14.04
|
|||||||
RUN mv /etc/cron.daily/logrotate /etc/cron.hourly/ \
|
RUN mv /etc/cron.daily/logrotate /etc/cron.hourly/ \
|
||||||
&& rm /etc/rsyslog.d/* \
|
&& rm /etc/rsyslog.d/* \
|
||||||
&& rm /etc/rsyslog.conf
|
&& rm /etc/rsyslog.conf
|
||||||
ADD rsyslog.conf /etc/rsyslog.conf
|
ADD make/common/log/rsyslog.conf /etc/rsyslog.conf
|
||||||
|
|
||||||
# logrotate configuration file for docker
|
# logrotate configuration file for docker
|
||||||
ADD logrotate_docker.conf /etc/logrotate.d/
|
ADD make/common/log/logrotate_docker.conf /etc/logrotate.d/
|
||||||
|
|
||||||
# rsyslog configuration file for docker
|
# rsyslog configuration file for docker
|
||||||
ADD rsyslog_docker.conf /etc/rsyslog.d/
|
ADD make/common/log/rsyslog_docker.conf /etc/rsyslog.d/
|
||||||
|
|
||||||
VOLUME /var/log/docker/
|
VOLUME /var/log/docker/
|
||||||
|
|
29
make/ubuntu/ui/Dockerfile
Normal file
29
make/ubuntu/ui/Dockerfile
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
FROM golang:1.6.2
|
||||||
|
|
||||||
|
MAINTAINER jiangd@vmware.com
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y libldap2-dev \
|
||||||
|
&& rm -r /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENV MYSQL_USR root \
|
||||||
|
MYSQL_PWD root \
|
||||||
|
REGISTRY_URL localhost:5000
|
||||||
|
|
||||||
|
RUN mkdir /harbor/
|
||||||
|
COPY ./make/dev/ui/harbor_ui /harbor/
|
||||||
|
|
||||||
|
COPY ./src/ui/views /harbor/views
|
||||||
|
COPY ./src/ui/static /harbor/static
|
||||||
|
COPY ./src/favicon.ico /harbor/favicon.ico
|
||||||
|
COPY ./make/jsminify.sh /tmp/jsminify.sh
|
||||||
|
|
||||||
|
RUN chmod u+x /harbor/harbor_ui \
|
||||||
|
&& sed -i 's/TLS_CACERT/#TLS_CAERT/g' /etc/ldap/ldap.conf \
|
||||||
|
&& sed -i '$a\TLS_REQCERT allow' /etc/ldap/ldap.conf \
|
||||||
|
&& /tmp/jsminify.sh /harbor/views/sections/script-include.htm /harbor/static/resources/js/harbor.app.min.js /harbor/
|
||||||
|
|
||||||
|
WORKDIR /harbor/
|
||||||
|
ENTRYPOINT ["/harbor/harbor_ui"]
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
@ -23,10 +23,10 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/astaxie/beego/validation"
|
"github.com/astaxie/beego/validation"
|
||||||
"github.com/vmware/harbor/auth"
|
"github.com/vmware/harbor/src/ui/auth"
|
||||||
"github.com/vmware/harbor/dao"
|
"github.com/vmware/harbor/src/common/dao"
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
"github.com/vmware/harbor/utils/log"
|
"github.com/vmware/harbor/src/common/utils/log"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
)
|
)
|
||||||
@ -156,13 +156,13 @@ func (b *BaseAPI) GetIDFromURL() int64 {
|
|||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
// set "Link" and "X-Total-Count" header for pagination request
|
// SetPaginationHeader set"Link" and "X-Total-Count" header for pagination request
|
||||||
func (b *BaseAPI) setPaginationHeader(total, page, pageSize int64) {
|
func (b *BaseAPI) SetPaginationHeader(total, page, pageSize int64) {
|
||||||
b.Ctx.ResponseWriter.Header().Set("X-Total-Count", strconv.FormatInt(total, 10))
|
b.Ctx.ResponseWriter.Header().Set("X-Total-Count", strconv.FormatInt(total, 10))
|
||||||
|
|
||||||
link := ""
|
link := ""
|
||||||
|
|
||||||
// set previous link
|
// SetPaginationHeader setprevious link
|
||||||
if page > 1 && (page-1)*pageSize <= total {
|
if page > 1 && (page-1)*pageSize <= total {
|
||||||
u := *(b.Ctx.Request.URL)
|
u := *(b.Ctx.Request.URL)
|
||||||
q := u.Query()
|
q := u.Query()
|
||||||
@ -174,7 +174,7 @@ func (b *BaseAPI) setPaginationHeader(total, page, pageSize int64) {
|
|||||||
link += fmt.Sprintf("<%s>; rel=\"prev\"", u.String())
|
link += fmt.Sprintf("<%s>; rel=\"prev\"", u.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// set next link
|
// SetPaginationHeader setnext link
|
||||||
if pageSize*page < total {
|
if pageSize*page < total {
|
||||||
u := *(b.Ctx.Request.URL)
|
u := *(b.Ctx.Request.URL)
|
||||||
q := u.Query()
|
q := u.Query()
|
||||||
@ -191,7 +191,8 @@ func (b *BaseAPI) setPaginationHeader(total, page, pageSize int64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseAPI) getPaginationParams() (page, pageSize int64) {
|
// GetPaginationParams ...
|
||||||
|
func (b *BaseAPI) GetPaginationParams() (page, pageSize int64) {
|
||||||
page, err := b.GetInt64("page", 1)
|
page, err := b.GetInt64("page", 1)
|
||||||
if err != nil || page <= 0 {
|
if err != nil || page <= 0 {
|
||||||
b.CustomAbort(http.StatusBadRequest, "invalid page")
|
b.CustomAbort(http.StatusBadRequest, "invalid page")
|
||||||
@ -210,7 +211,8 @@ func (b *BaseAPI) getPaginationParams() (page, pageSize int64) {
|
|||||||
return page, pageSize
|
return page, pageSize
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIsInsecure() bool {
|
// GetIsInsecure ...
|
||||||
|
func GetIsInsecure() bool {
|
||||||
insecure := false
|
insecure := false
|
||||||
|
|
||||||
verifyRemoteCert := os.Getenv("VERIFY_REMOTE_CERT")
|
verifyRemoteCert := os.Getenv("VERIFY_REMOTE_CERT")
|
@ -19,8 +19,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
"github.com/vmware/harbor/utils/log"
|
"github.com/vmware/harbor/src/common/utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddAccessLog persists the access logs
|
// AddAccessLog persists the access logs
|
@ -22,7 +22,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
"github.com/vmware/harbor/utils/log"
|
"github.com/vmware/harbor/src/common/utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NonExistUserID : if a user does not exist, the ID of the user will be 0.
|
// NonExistUserID : if a user does not exist, the ID of the user will be 0.
|
@ -21,9 +21,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
"github.com/vmware/harbor/utils"
|
"github.com/vmware/harbor/src/common/utils"
|
||||||
"github.com/vmware/harbor/utils/log"
|
"github.com/vmware/harbor/src/common/utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func execUpdate(o orm.Ormer, sql string, params ...interface{}) error {
|
func execUpdate(o orm.Ormer, sql string, params ...interface{}) error {
|
@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
_ "github.com/go-sql-driver/mysql" //register mysql driver
|
_ "github.com/go-sql-driver/mysql" //register mysql driver
|
||||||
"github.com/vmware/harbor/utils/log"
|
"github.com/vmware/harbor/src/common/utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type mysql struct {
|
type mysql struct {
|
@ -16,12 +16,12 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/vmware/harbor/utils/log"
|
"github.com/vmware/harbor/src/common/utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
//TODO:transaction, return err
|
//TODO:transaction, return err
|
@ -19,7 +19,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDeleteProject(t *testing.T) {
|
func TestDeleteProject(t *testing.T) {
|
@ -16,7 +16,7 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddProjectMember inserts a record to table project_member
|
// AddProjectMember inserts a record to table project_member
|
@ -19,8 +19,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
"github.com/vmware/harbor/utils"
|
"github.com/vmware/harbor/src/common/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register is used for user to register, the password is encrypted before the record is inserted into database.
|
// Register is used for user to register, the password is encrypted before the record is inserted into database.
|
@ -22,7 +22,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddRepTarget ...
|
// AddRepTarget ...
|
@ -20,7 +20,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddRepository adds a repo to the database.
|
// AddRepository adds a repo to the database.
|
@ -18,7 +18,7 @@ package dao
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
@ -19,7 +19,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetUserProjectRoles returns roles that the user has according to the project.
|
// GetUserProjectRoles returns roles that the user has according to the project.
|
@ -20,10 +20,10 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
"github.com/vmware/harbor/utils"
|
"github.com/vmware/harbor/src/common/utils"
|
||||||
|
|
||||||
"github.com/vmware/harbor/utils/log"
|
"github.com/vmware/harbor/src/common/utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetUser ...
|
// GetUser ...
|
@ -19,7 +19,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/vmware/harbor/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDeleteUser(t *testing.T) {
|
func TestDeleteUser(t *testing.T) {
|
@ -19,7 +19,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/astaxie/beego/validation"
|
"github.com/astaxie/beego/validation"
|
||||||
"github.com/vmware/harbor/utils"
|
"github.com/vmware/harbor/src/common/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user