yapi是一个接口管理工具,如何使用可以参考官方的使用说明,这里就不多说了,可以参考:https://hellosean1025.github.io/yapi/documents/index.html 下面看一下如何使用docker部署,首先我们需要安装docker,可以参考:https://www.wulaoer.org/?p=260
先把yapi的项目git下来,这里是使用别人对yapi二次开发的环境,所以和原环境不太一样,
[root@wulaoer.org ~]# cd /apps/work/service/ [root@wulaoer.org service]# git clone https://gitee.com/fjc0k/docker-YApi.git Cloning into 'docker-YApi'... remote: Enumerating objects: 460, done. remote: Counting objects: 100% (460/460), done. remote: Compressing objects: 100% (201/201), done. remote: Total 460 (delta 253), reused 425 (delta 232), pack-reused 0 Receiving objects: 100% (460/460), 80.10 KiB | 0 bytes/s, done. Resolving deltas: 100% (253/253), done. [root@wulaoer.org service]# cd docker-YApi [root@wulaoer.org docker-YApi]#
yapi的docker配置文件已经git下来了,下面配置一下yapi的信息,yapi的存储使用的是mongodb,在配置文件中会自动拉取一个mongodb的镜像并把启动的容器关联到yapi,看下配置信息
[root@wulaoer.org docker-YApi]# cat docker-compose.yml 原文件内容: version: '3' services: yapi-web: image: jayfong/yapi:latest container_name: yapi-web ports: - 40001:3000 environment: - YAPI_ADMIN_ACCOUNT=admin@docker.yapi - YAPI_ADMIN_PASSWORD=adm1n - YAPI_CLOSE_REGISTER=true - YAPI_DB_SERVERNAME=yapi-mongo - YAPI_DB_PORT=27017 - YAPI_DB_DATABASE=yapi - YAPI_MAIL_ENABLE=false - YAPI_LDAP_LOGIN_ENABLE=false - YAPI_PLUGINS=[] depends_on: - yapi-mongo links: - yapi-mongo restart: unless-stopped yapi-mongo: image: mongo:latest container_name: yapi-mongo volumes: - ./data/db:/data/db expose: - 27017 restart: unless-stopped 添加ldap后只是把ldap的变量信息添加到配置文件中。 version: '3' services: yapi-web: image: jayfong/yapi:latest container_name: yapi-web ports: - 40001:3000 environment: - YAPI_ADMIN_ACCOUNT=admin@XXXXXXX.cn - YAPI_ADMIN_PASSWORD=admin - YAPI_CLOSE_REGISTER=true #禁用注册 - YAPI_DB_SERVERNAME=yapi-mongo - YAPI_DB_PORT=27017 - YAPI_DB_DATABASE=yapi - YAPI_MAIL_ENABLE=false - YAPI_LDAP_LOGIN_ENABLE=true #开启ldap - YAPI_LDAP_LOGIN_SERVER=ldap://10.16.202.178:389 - YAPI_LDAP_LOGIN_BASE_DN=cn=admin,dc=XXXXXXX,dc=cn - YAPI_LDAP_LOGIN_BIND_PASSWORD=XXXXXXX - YAPI_LDAP_LOGIN_SEARCH_DN=ou=user,dc=XXXXXXX,dc=cn - YAPI_LDAP_LOGIN_SEARCH_STANDARD=uid - YAPI_PLUGINS=[] depends_on: - yapi-mongo links: - yapi-mongo restart: unless-stopped yapi-mongo: image: mongo:latest container_name: yapi-mongo volumes: - ./data/db:/data/db expose: - 27017 restart: unless-stopped
我们可以根据自己的需求,修改docker映射端口,关联mongodb等信息,还有就是ldap的信息,我这里直接修改后启动。
[root@wulaoer.org docker-YApi]# pip install docker-compose [root@wulaoer.org docker-YApi]# docker-compose up -d
会根据配置信息拉取数据进行创建容器,这里也就是创建了一个自定义的镜像然后把配置信息传到容器并启动起来。看一下容器的状态:
[root@wulaoer.org docker-YApi]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1af79f3aa2c9 jayfong/yapi:latest "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:40001->3000/tcp yapi-web 3968531b9e88 mongo:latest "docker-entrypoint.s…" 2 hours ago Up 2 hours 27017/tcp yapi-mongo
yapi搭建好了,可以访问http://IP:40001访问,看下面的页面
因为yapi是针对公司内部使用,所以不允许用户随便注册,所以需要禁用注册。上面配置中已经禁用注册,可以看看效果:
后期有什么其他的功能会在补充,没有新的东西了,看些其他的吧。
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏