From cb78c5cd7e9dde7de4bc32f56caec405ab1565d5 Mon Sep 17 00:00:00 2001 From: Tan Jiang Date: Fri, 1 Apr 2016 18:54:21 +0800 Subject: [PATCH 1/5] switch to v2 format docker compose template --- Deploy/docker-compose.yml | 135 +++++++++++++++------------ Deploy/prepare | 1 + Deploy/templates/registry/config.yml | 2 +- Deploy/templates/ui/env | 2 + dao/base.go | 13 +-- 5 files changed, 80 insertions(+), 73 deletions(-) diff --git a/Deploy/docker-compose.yml b/Deploy/docker-compose.yml index d7a3ba547a..02e1359195 100644 --- a/Deploy/docker-compose.yml +++ b/Deploy/docker-compose.yml @@ -1,62 +1,73 @@ -log: - build: ./log/ - volumes: - - /var/log/harbor/:/var/log/docker/ - ports: - - 1514:514 -registry: - image: library/registry:2.3.0 - volumes: - - /data/registry:/storage - - ./config/registry/:/etc/registry/ - ports: - - 5001:5001 - command: - /etc/registry/config.yml - links: - - log - log_driver: "syslog" - log_opt: - syslog-address: "tcp://127.0.0.1:1514" - syslog-tag: "registry" -mysql: - build: ./db/ - volumes: - - /data/database:/var/lib/mysql - env_file: - - ./config/db/env - links: - - log - log_driver: "syslog" - log_opt: - syslog-address: "tcp://127.0.0.1:1514" - syslog-tag: "mysql" -ui: - build: ../ - env_file: - - ./config/ui/env - volumes: - - ./config/ui/app.conf:/etc/ui/app.conf - - ./config/ui/private_key.pem:/etc/ui/private_key.pem - links: - - registry - - mysql - - log - log_driver: "syslog" - log_opt: - syslog-address: "tcp://127.0.0.1:1514" - syslog-tag: "ui" -proxy: - image: library/nginx:1.9 - volumes: - - ./config/nginx:/etc/nginx - links: - - ui - - registry - - log - ports: - - 80:80 - log_driver: "syslog" - log_opt: - syslog-address: "tcp://127.0.0.1:1514" - syslog-tag: "proxy" +version: '2' +services: + log: + build: ./log/ + volumes: + - /var/log/harbor/:/var/log/docker/ + ports: + - 1514:514 + registry: + image: library/registry:2.3.0 + volumes: + - /data/registry:/storage + - ./config/registry/:/etc/registry/ + ports: + - 5001:5001 + command: + /etc/registry/config.yml + depends_on: + - log + logging: + driver: "syslog" + options: + syslog-address: "tcp://127.0.0.1:1514" + syslog-tag: "registry" + mysql: + build: ./db/ + volumes: + - /data/database:/var/lib/mysql + env_file: + - ./config/db/env + depends_on: + - log + logging: + driver: "syslog" + options: + syslog-address: "tcp://127.0.0.1:1514" + syslog-tag: "mysql" + ui: + build: ../ + env_file: + - ./config/ui/env + networks: + default: + aliases: + - ui + volumes: + - ./config/ui/app.conf:/etc/ui/app.conf + - ./config/ui/private_key.pem:/etc/ui/private_key.pem + depends_on: + - log + links: + - mysql + logging: + driver: "syslog" + options: + syslog-address: "tcp://127.0.0.1:1514" + syslog-tag: "ui" + proxy: + image: library/nginx:1.9 + volumes: + - ./config/nginx:/etc/nginx + ports: + - 80:80 + depends_on: + - mysql + - registry + - ui + - log + logging: + driver: "syslog" + options: + syslog-address: "tcp://127.0.0.1:1514" + syslog-tag: "proxy" diff --git a/Deploy/prepare b/Deploy/prepare index 76f3d03562..db05abcbe3 100755 --- a/Deploy/prepare +++ b/Deploy/prepare @@ -60,6 +60,7 @@ for f in conf_files: render(os.path.join(templates_dir, "ui", "env"), ui_conf_env, hostname=hostname, + db_password=db_password, ui_url=ui_url, auth_mode=auth_mode, admin_pwd=harbor_admin_password, diff --git a/Deploy/templates/registry/config.yml b/Deploy/templates/registry/config.yml index 83134a9f63..f460bf13e2 100644 --- a/Deploy/templates/registry/config.yml +++ b/Deploy/templates/registry/config.yml @@ -27,7 +27,7 @@ notifications: endpoints: - name: harbor disabled: false - url: $ui_url/service/notifications + url: http://ui/service/notifications timeout: 500 threshold: 5 backoff: 1000 diff --git a/Deploy/templates/ui/env b/Deploy/templates/ui/env index 8fe9710c12..f52d7c5bee 100644 --- a/Deploy/templates/ui/env +++ b/Deploy/templates/ui/env @@ -1,5 +1,7 @@ MYSQL_HOST=mysql +MYSQL_PORT=3306 MYSQL_USR=root +MYSQL_PWD=$db_password REGISTRY_URL=http://registry:5000 CONFIG_PATH=/etc/ui/app.conf HARBOR_REG_URL=$hostname diff --git a/dao/base.go b/dao/base.go index 3afb633cf7..49419745e6 100644 --- a/dao/base.go +++ b/dao/base.go @@ -66,18 +66,11 @@ func GenerateRandomString() (string, error) { func InitDB() { orm.RegisterDriver("mysql", orm.DRMySQL) addr := os.Getenv("MYSQL_HOST") - if len(addr) == 0 { - addr = os.Getenv("MYSQL_PORT_3306_TCP_ADDR") - } - - port := os.Getenv("MYSQL_PORT_3306_TCP_PORT") + port := os.Getenv("MYSQL_PORT") username := os.Getenv("MYSQL_USR") + password := os.Getenv("MYSQL_PWD") - password := os.Getenv("MYSQL_ENV_MYSQL_ROOT_PASSWORD") - if len(password) == 0 { - password = os.Getenv("MYSQL_PWD") - } - + log.Debugf("db url: %s:%s, db user: %s", addr, port, username) dbStr := username + ":" + password + "@tcp(" + addr + ":" + port + ")/registry" ch := make(chan int, 1) go func() { From 0c00869faa816acb5ff325bfbe45c858d18bed53 Mon Sep 17 00:00:00 2001 From: Tan Jiang Date: Fri, 1 Apr 2016 19:13:04 +0800 Subject: [PATCH 2/5] tiny update to logger --- utils/log/logger.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/log/logger.go b/utils/log/logger.go index 27fc92610b..c713aa1b01 100644 --- a/utils/log/logger.go +++ b/utils/log/logger.go @@ -263,12 +263,12 @@ func line(calldepth int) string { line = 0 } - for i := len(file) - 1; i > 0; i-- { - if file[i] == '/' { + for i := len(file) - 2; i > 0; i-- { + if file[i] == os.PathSeparator { file = file[i+1:] break } } - return fmt.Sprintf("%s:%d", file, line) + return fmt.Sprintf("[%s:%d]:", file, line) } From 72b9198e8e02988ed09dc44389612fc66a47e669 Mon Sep 17 00:00:00 2001 From: Tan Jiang Date: Fri, 1 Apr 2016 19:23:31 +0800 Subject: [PATCH 3/5] fix UT breakage: --- dao/dao_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dao/dao_test.go b/dao/dao_test.go index 7e9e1e0d23..abb671b3ff 100644 --- a/dao/dao_test.go +++ b/dao/dao_test.go @@ -128,8 +128,8 @@ func TestMain(m *testing.M) { log.Infof("DB_HOST: %s, DB_USR: %s, DB_PORT: %s, DB_PWD: %s\n", dbHost, dbUser, dbPort, dbPassword) - os.Setenv("MYSQL_PORT_3306_TCP_ADDR", dbHost) - os.Setenv("MYSQL_PORT_3306_TCP_PORT", dbPort) + os.Setenv("MYSQL_HOST", dbHost) + os.Setenv("MYSQL_PORT", dbPort) os.Setenv("MYSQL_USR", dbUser) os.Setenv("MYSQL_PWD", dbPassword) os.Setenv("AUTH_MODE", "db_auth") From 118bdde8dffac1035a03952ba011fa1135292079 Mon Sep 17 00:00:00 2001 From: Tan Jiang Date: Fri, 1 Apr 2016 23:11:49 +0800 Subject: [PATCH 4/5] remove unnecessary chunks --- Deploy/docker-compose.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Deploy/docker-compose.yml b/Deploy/docker-compose.yml index 02e1359195..2a223cd95f 100644 --- a/Deploy/docker-compose.yml +++ b/Deploy/docker-compose.yml @@ -39,17 +39,11 @@ services: build: ../ env_file: - ./config/ui/env - networks: - default: - aliases: - - ui volumes: - ./config/ui/app.conf:/etc/ui/app.conf - ./config/ui/private_key.pem:/etc/ui/private_key.pem depends_on: - log - links: - - mysql logging: driver: "syslog" options: From 07887fd658c3769b367d0d032a7f86c5690f8bbb Mon Sep 17 00:00:00 2001 From: Tan Jiang Date: Sat, 2 Apr 2016 14:29:59 +0800 Subject: [PATCH 5/5] update docker version in installation guide --- docs/installation_guide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/installation_guide.md b/docs/installation_guide.md index c4b2174934..1a7ddf3fa9 100644 --- a/docs/installation_guide.md +++ b/docs/installation_guide.md @@ -5,7 +5,7 @@ Harbor can be installed from the source code by using "docker-compose up" comman Harbor is deployed as several Docker containers. Hence, it can be deployed on any Linux distribution that supports Docker. Before deploying Harbor, the target machine requires Python, Docker, Docker Compose to be installed. * Python should be version 2.7 or higher. Some Linux distributions (Gentoo, Arch) may not have a Python interpreter installed by default. On those systems, you need to install Python manually. -* The Docker engine should be version 1.8 or higher. For the details to install Docker engine, please refer to: https://docs.docker.com/engine/installation/ +* The Docker engine should be version 1.10 or higher. For the details to install Docker engine, please refer to: https://docs.docker.com/engine/installation/ * The Docker Compose needs to be version 1.6.0 or higher. For the details to install Docker compose, please refer to: https://docs.docker.com/compose/install/ ### Configuration of Harbor @@ -139,4 +139,4 @@ Removing harbor_mysql_1 ... done ### Persistent data and log files By default, the data of database and image files in the registry are persisted in the directory **/data/** of the target machine. When Harbor's containers are removed and recreated, the data remain unchanged. -Harbor leverages rsyslog to collect the logs of each container, by default the log files are stored in the directory **/var/log/harbor/** on Harbor's host. \ No newline at end of file +Harbor leverages rsyslog to collect the logs of each container, by default the log files are stored in the directory **/var/log/harbor/** on Harbor's host.