应用镜像: yapipro/yapi:latest,mongo:latest
1.1.1.1为本地私有仓库地址
1.yapi net 创建
docker network create yapi
2.mongo安装
docker run -d \
--name mongodb \
--restart always \
--net=yapi \
-p 27017:27017 \
-v /data/yapi/mongodata:/data/db \
-e MONGO_INITDB_DATABASE=yapi \
-e MONGO_INITDB_ROOT_USERNAME=yapipro \
-e MONGO_INITDB_ROOT_PASSWORD=initpassword \
1.1.1.1:5000/mongo:latest
3.mongo配置
#登录进容器
#登录进mongo
use admin;
db.auth("yapipro", "initpassword");
use yapi;
db.createUser({
user: 'yapi',
pwd: 'password',
roles: [
{ role: "dbAdmin", db: "yapi" },
{ role: "readWrite", db: "yapi" }
]
});
4.YApi config.json配置
{
"port": "3000",
"adminAccount": "xxx@yyy.com",
"closeRegister":true,
"timeout":120000,
"db": {
"servername": "mongo",
"DATABASE": "yapi",
"port": 27017,
"user": "yapi",
"pass": "password",
"authSource": ""
},
"mail": {
"enable": true,
"host": "zzz.yyy.com",
"port": 465,
"from": "*",
"auth": {
"user": "yapi.service",
"pass": "xxxxxxxxxx"
}
},
"ldapLogin": {
"enable": true,
"server": "ldap://xxxxx:389",
"baseDn": "CN=yapi service,OU=Public,DC=yyy,DC=com",
"bindPassword": "xxxxxx",
"searchDn": "OU=yyy,DC=yyy,DC=com",
"searchStandard": "&(objectClass=person)(sAMAccountName=%s)",
"usernameKey": "sAMAccountName"
}
}
5.YApi 初始化
docker run -d --rm \
--name yapi-init \
--link mongodb:mongo \
--net=yapi \
-v $PWD/config.json:/yapi/config.json \
1.1.1.1:5000/yapi:latest \
server/install.js
6.YApi 启动
docker run -d \
--name yapi \
--link mongodb:mongo \
--restart always \
--net=yapi \
-p 3000:3000 \
-v $PWD/config.json:/yapi/config.json \
1.1.1.1:5000/yapi:latest \
server/app.js