switch to v2 format docker compose template

This commit is contained in:
Tan Jiang 2016-04-01 18:54:21 +08:00
parent 9004e4ef82
commit cb78c5cd7e
5 changed files with 80 additions and 73 deletions

View File

@ -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"

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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() {