Docker installs YApi documentation tool

Ypai also requires Node environment and MongoDb before installation. Please install it yourself.

1. Pull the image

docker pull registry.cn-hangzhou.aliyuncs.com/anoy/yapi

2. Check whether the image is downloaded

docker images
Insert image description here

3. Run mongo first

docker run --restart always -v /data/mongodb:/data/db -d --name mongodb mongo

–restart always is the restart strategy
-v /data/mongodb:/data/db -v is the mounting path format, which is the host path: the path in the container
-d means running in the background
–name container name

4. After running mongo, run the yapi container initialization

docker run -it --rm --link mongodb:mongo --entrypoint npm --workdir /api/vendors registry.cn-hangzhou.aliyuncs.com/anoy/yapi run install-server

–link mongodb: mongo is the container address bound to mongo, and mongodb is the container name. I won’t go into details about link. Regarding the network,
after initializing Yapi, the initialized account password will be displayed.
The administrator account was initialized successfully, account name: "[email protected]", password: "ymfe.org"

5. Run yapi

docker run -d --restart=always --name yapi --link mongodb:mongo --workdir /api/vendors -p 3001:3000 registry.cn-hangzhou.aliyuncs.com/anoy/yapi server/app.js

Even if it is completed at this point, the cloud server needs to open the exposed port in the security group. If you don’t want others to register casually, you can do this.

docker exec  -it yapi /bin/sh

vi ../config.json 

#修改内容如下
{
  "port": "3000",
  "adminAccount": "[email protected]",
  "closeRegister":true, #主要是添加这句配置,这个配置是禁用注册
  "db": {
    "servername": "mongo",
    "DATABASE": "yapi",
    "port": 27017
  }
}
#保存后退出

exit #退出容器

docker restart yapi #重启服务

How to add users after disabling registration? Log in to Yapi, then add a project and add a registration user interface.

The address is: http://yapi:port/api/user/reg

POST json

{
  "email": "[email protected]",
  "password": "[email protected]",
  "username": "xxxx"
}

After each registration is completed, you need to exit and re-enter, otherwise there will be session collapse problems.

This requires two tools:
1. Online debugging plug-in: link: https://pan.baidu.com/s/1-AbOzZcAlDk9kFeT-ZCKeg
extraction code: yzjx
2. Google extension plug-in: link: https://pan. baidu.com/s/1WYUGmkmqwWRCFdDD4Udrgg
extraction code: 41k4
Google extension plug-in tutorial: https://juejin.im/post/5e3bbd986fb9a07ce152b53d

Thumbs up for Chinese programmers! ! !

Guess you like

Origin blog.csdn.net/qq_45699784/article/details/121728288