Giter Site home page Giter Site logo

fjc0k / docker-yapi Goto Github PK

View Code? Open in Web Editor NEW
1.1K 9.0 259.0 91 KB

接口管理平台 YApi 的 Docker 镜像。

Home Page: https://hub.docker.com/r/jayfong/yapi/tags

License: MIT License

Dockerfile 6.63% TypeScript 93.37%
docker docker-image yapi yapi-docker docker-yapi yapi-docker-compose

docker-yapi's Issues

阿里云服务器 部署时 访问502

在阿里云上部署,配置npm的镜像源和安装的插件 。docker-compose up后服务正常启动,使用nginx代理,访问出现502。删除compose文件中npm镜像,以及设置YAPI_PLUGINS默认后,重新部署,可以正常访问

安装有插件时启动花费很长时间怎么解决?

兄弟,请问下,每次启动都是重新安装插件,这个步骤需要浪费大量的时间,还有优化的空间吗?
是否可以预先定义好插件,在打docker镜像的时候将插件也弄好,这样每次启动就可以节省很多时间了

Starting yapi-mongo ... error

WARNING: The Docker Engine you're using is running in swarm mode.

Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.

To deploy your application across the swarm, use docker stack deploy.

Starting yapi-mongo ... error

ERROR: for yapi-mongo Cannot start service yapi-mongo: Could not attach to network 7da9142ae8e2603e0abcffcd68b9970c35f831c9a4eba19c2b2121a961919eed: rpc error: code = NotFound desc = network 7da9142ae8e2603e0abcffcd68b9970c35f831c9a4eba19c2b2121a961919eed not found

ERROR: for yapi-mongo Cannot start service yapi-mongo: Could not attach to network 7da9142ae8e2603e0abcffcd68b9970c35f831c9a4eba19c2b2121a961919eed: rpc error: code = NotFound desc = network 7da9142ae8e2603e0abcffcd68b9970c35f831c9a4eba19c2b2121a961919eed not found
ERROR: Encountered errors while bringing up the project.

如何添加yapi-plugin-export-docx-data插件

如题

按照- YAPI_PLUGINS=[{"name":"yapi-plugin-export-docx-data"},日志出现:

yapi-web | Error: 初始化管理员账号 "[email protected]" 失败, E11000 duplicate key error collection: yapi.user index: email_1 dup key: { email: "[email protected]" }
yapi-web | at /yapi/vendors/server/install.js:146:17
yapi-web | at processTicksAndRejections (internal/process/task_queues.js:97:5)
yapi-web |
yapi-web | 关闭引导服务...
yapi-web | 尝试启动 YApi...
yapi-web | (node:1) UnhandledPromiseRejectionWarning: Error: Cannot find module 'yapi-plugin-yapi-plugin-export-docx-data'

另外,这个插件似乎“需要在vendors目录下新建input.docx模板文件

🎈被迫安装 user-add 插件引发的问题与思考!

您的 docker-compose 项目做的非常不错 ! 我在安装中遇到一点小问题, 并提交了相关的 PR,

  • CentOS version: centos-release-7-6.1810.2.el7.centos.x86_64
  • Docker version: Docker version 19.03.8, build afacb8b
  • docker-compose version : 1.18.0, build 8dd22a9
  • node version: v12.16.1

#17 问题如何发生:

我 在 yapi 项目 readme 中发现了这个项目.
我使用了最新的 node 以及 docker 来 运行这个项目,
将项目 clone 到本地, 修改了按您的readme中的提示, 修改的用户名以及密码,
将项目启动, 登录使用都没有异常, 但发现了一个问题就是, yapi 无法注册用户,
看了日志并没有错误. 我看见了 插件列表中的 user-add 插件可以解决这个问题. 我安装了那个插件.
但是发现了下面的错误. 貌似关于 init.lock. 以我的 nodejs 水平, 暂时无法解决这个问题,
也可能是我操作的问题, 可以一起来完善下插件相关的文档,
我选择了修改 YAPI_CLOSE_REGISTER 为 false 后重新安装容器后可以注册用户.

🍰 yapi-web 日志

yapi-web      | 启动引导服务...
yapi-web      | 写入配置...
yapi-web      | {
yapi-web      |   "adminAccount": "[email protected]",
yapi-web      |   "db": {
yapi-web      |     "servername": "yapi-mongo",
yapi-web      |     "port": 27017,
yapi-web      |     "DATABASE": "yapi"
yapi-web      |   },
yapi-web      |   "mail": {
yapi-web      |     "enable": false,
yapi-web      |     "auth": {}
yapi-web      |   },
yapi-web      |   "ldapLogin": {
yapi-web      |     "enable": false
yapi-web      |   },
yapi-web      |   "closeRegister": false,
yapi-web      |   "plugins": {
yapi-web      |     "name": "add-user"
yapi-web      |   },
yapi-web      |   "adminPassword": "Password",
yapi-web      |   "port": 3000
yapi-web      | }
yapi-web      | 等待 MongoDB 服务可用...
yapi-web      | 安装 YApi 插件...
yapi-web      | 尝试安装 YApi...
yapi-web      | + node '--unhandled-rejections=strict' ./vendors/server/install.js
yapi-web      | 
yapi-web      | (node:17) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
yapi-web      | 
yapi-web      | log: mongodb load success...
yapi-web      | 
yapi-web      | 初始化管理员账号成功,账号名:"[email protected]",密码:"Password"
yapi-web      | 
yapi-web      | 关闭引导服务...
yapi-web      | 尝试启动 YApi...
yapi-web      | (node:1) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
yapi-web      | (node:1) UnhandledPromiseRejectionWarning: Error: 插件配置有误,请检查
yapi-web      |     at exports.initPlugins (/yapi/vendors/common/plugin.js:30:11)
yapi-web      |     at Object.<anonymous> (/yapi/vendors/server/plugin.js:235:21)
yapi-web      |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
yapi-web      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
yapi-web      |     at Module.load (internal/modules/cjs/loader.js:996:32)
yapi-web      |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
yapi-web      |     at Module.require (internal/modules/cjs/loader.js:1036:19)
yapi-web      |     at require (internal/modules/cjs/helpers.js:72:18)
yapi-web      |     at Object.<anonymous> (/yapi/vendors/server/app.js:10:1)
yapi-web      |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
yapi-web      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
yapi-web      |     at Module.load (internal/modules/cjs/loader.js:996:32)
yapi-web      |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
yapi-web      |     at Module.require (internal/modules/cjs/loader.js:1036:19)
yapi-web      |     at require (internal/modules/cjs/helpers.js:72:18)
yapi-web      |     at Main.start (/yapi/start.js:340:9)
yapi-web      | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
yapi-web      | (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
yapi-web      | log: mongodb load success...
yapi-web      | 启动引导服务...
yapi-web      | 写入配置...
yapi-web      | {
yapi-web      |   "adminAccount": "[email protected]",
yapi-web      |   "db": {
yapi-web      |     "servername": "yapi-mongo",
yapi-web      |     "port": 27017,
yapi-web      |     "DATABASE": "yapi"
yapi-web      |   },
yapi-web      |   "mail": {
yapi-web      |     "enable": false,
yapi-web      |     "auth": {}
yapi-web      |   },
yapi-web      |   "ldapLogin": {
yapi-web      |     "enable": false
yapi-web      |   },
yapi-web      |   "closeRegister": false,
yapi-web      |   "plugins": {
yapi-web      |     "name": "add-user"
yapi-web      |   },
yapi-web      |   "adminPassword": "Password",
yapi-web      |   "port": 3000
yapi-web      | }
yapi-web      | 等待 MongoDB 服务可用...
yapi-web      | 安装 YApi 插件...
yapi-web      | 尝试安装 YApi...
yapi-web      | + node '--unhandled-rejections=strict' ./vendors/server/install.js
yapi-web      | 
yapi-web      | /yapi/vendors/server/install.js:15
yapi-web      |     throw new Error(
yapi-web      |     ^
yapi-web      | 
yapi-web      | Error: init.lock文件已存在,请确认您是否已安装。如果需要重新安装,请删掉init.lock文件
yapi-web      |     at install (/yapi/vendors/server/install.js:15:11)
yapi-web      |     at Object.<anonymous> (/yapi/vendors/server/install.js:155:1)
yapi-web      |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
yapi-web      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
yapi-web      |     at Module.load (internal/modules/cjs/loader.js:996:32)
yapi-web      |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
yapi-web      |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
yapi-web      |     at internal/main/run_main_module.js:17:47
yapi-web      | 
yapi-web      | 关闭引导服务...
yapi-web      | 尝试启动 YApi...
yapi-web      | (node:1) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
yapi-web      | (node:1) UnhandledPromiseRejectionWarning: Error: 插件配置有误,请检查
yapi-web      |     at exports.initPlugins (/yapi/vendors/common/plugin.js:30:11)
yapi-web      |     at Object.<anonymous> (/yapi/vendors/server/plugin.js:235:21)
yapi-web      |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
yapi-web      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
yapi-web      |     at Module.load (internal/modules/cjs/loader.js:996:32)
yapi-web      |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
yapi-web      |     at Module.require (internal/modules/cjs/loader.js:1036:19)
yapi-web      |     at require (internal/modules/cjs/helpers.js:72:18)
yapi-web      |     at Object.<anonymous> (/yapi/vendors/server/app.js:10:1)
yapi-web      |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
yapi-web      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
yapi-web      |     at Module.load (internal/modules/cjs/loader.js:996:32)
yapi-web      |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
yapi-web      |     at Module.require (internal/modules/cjs/loader.js:1036:19)
yapi-web      |     at require (internal/modules/cjs/helpers.js:72:18)
yapi-web      |     at Main.start (/yapi/start.js:340:9)
yapi-web      | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
yapi-web      | (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

补救方式:

建议将 YAPI_CLOSE_REGISTER 默认设置为 false , 可以在第一次运行时就不会出现这样的连环问题.

更新完YAPI_PLUGINS=[{"name":"add-user"}] 后,报错

yapi-web | [error] ./exts/yapi-plugin-advanced-mock/MockCol/CaseDesModal.scss
yapi-web | Module build failed: Error: Missing binding /yapi/vendors/node_modules/node-sass/vendor/linux_musl-x64-83/binding.node
yapi-web | Node Sass could not find a binding for your current environment: Linux/musl 64-bit with Node.js 14.x
yapi-web |
yapi-web | Found bindings for the following environments:
yapi-web | - Linux/musl 64-bit with Node.js 13.x
yapi-web |
yapi-web | This usually happens because your environment has changed since running npm install.
yapi-web | Run npm rebuild node-sass to download the binding for your current environment.
yapi-web | at module.exports (/yapi/vendors/node_modules/node-sass/lib/binding.js:15:13)
yapi-web | at Object. (/yapi/vendors/node_modules/node-sass/lib/index.js:14:35)
yapi-web | at Module._compile (internal/modules/cjs/loader.js:1185:30)
yapi-web | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
yapi-web | at Module.load (internal/modules/cjs/loader.js:1034:32)
yapi-web | at Function.Module._load (internal/modules/cjs/loader.js:923:14)
yapi-web | at Module.require (internal/modules/cjs/loader.js:1074:19)
yapi-web | at require (internal/modules/cjs/helpers.js:72:18)
yapi-web | at Object.sassLoader (/yapi/vendors/node_modules/sass-loader/lib/loader.js:24:22)
yapi-web | @ ./exts/yapi-plugin-advanced-mock/MockCol/CaseDesModal.js 103:0-30
yapi-web |
yapi-web |
yapi-web | npm
yapi-web | ERR! code ELIFECYCLE
yapi-web |
yapi-web | npm
yapi-web | ERR! errno
yapi-web | 1
yapi-web |
yapi-web | npm
yapi-web | ERR! [email protected] build-client: NODE_ENV=production ykit pack -m
yapi-web | npm
yapi-web | ERR! Exit status 1
yapi-web | npm
yapi-web | ERR!
yapi-web | npm
yapi-web | ERR! Failed at the [email protected] build-client script.
yapi-web | npm ERR!
yapi-web | This is probably not a problem with npm. There is likely additional logging output above.
yapi-web |
yapi-web |
yapi-web |
yapi-web | npm ERR! A complete log of this run can be found in:
yapi-web | npm ERR! /root/.npm/_logs/2020-05-21T02_25_29_877Z-debug.log
yapi-web |
yapi-web | 尝试安装 YApi...
yapi-web | + node '--unhandled-rejections=strict' ./vendors/server/install.js
yapi-web |
yapi-web | (node:93) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
yapi-web | (Use node --trace-warnings ... to show where the warning was created)
yapi-web |
yapi-web | (node:93) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
yapi-web |
yapi-web | (node:93) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
yapi-web | (node:93) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
yapi-web |
yapi-web | log: mongodb load success...
yapi-web |
yapi-web | /yapi/vendors/server/install.js:146
yapi-web | throw new Error(初始化管理员账号 "${yapi.WEBCONFIG.adminAccount}" 失败, ${err.message}); // eslint-disable-line
yapi-web | ^
yapi-web |
yapi-web | Error: 初始化管理员账号 "[email protected]" 失败, E11000 duplicate key error collection: yapi.user index: email_1 dup key: { email: "[email protected]" }
yapi-web | at /yapi/vendors/server/install.js:146:17
yapi-web | at processTicksAndRejections (internal/process/task_queues.js:97:5)
yapi-web |
yapi-web | 关闭引导服务...
yapi-web | 尝试启动 YApi...
yapi-web | log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
yapi-web | log: 服务已启动,请打开下面链接访问:
yapi-web | http://127.0.0.1:3000/
yapi-web | (node:1) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
yapi-web | (Use node --trace-warnings ... to show where the warning was created)
yapi-web | (node:1) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
yapi-web | (node:1) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
yapi-web | (node:1) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
yapi-web | log: mongodb load success...
yapi-web | (node:1) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated

使用插件后,在哪里配置插件?

在docker-compose.yaml里面添加了插件yapi-plugin-webhook,并且重启后安装成功。
但是该插件需要配置,那么在docker exec进入容器后应该配置哪个文件呢? #

MongoNetworkError: Authentication failed., mongodb Authentication failed

Attaching to yapi-web
yapi-web | 启动引导服务...
yapi-web | 写入配置...
yapi-web | {
yapi-web | "plugins": [
yapi-web | {
yapi-web | "name": "add-user",
yapi-web | "options": {}
yapi-web | }
yapi-web | ],
yapi-web | "adminAccount": "[email protected]",
yapi-web | "adminPassword": "adm1n",
yapi-web | "closeRegister": true,
yapi-web | "db": {
yapi-web | "servername": "yapi-mongo",
yapi-web | "port": 27017,
yapi-web | "DATABASE": "yapi",
yapi-web | "user": "root",
yapi-web | "pass": "0000",
yapi-web | "authSource": "admin"
yapi-web | },
yapi-web | "mail": {
yapi-web | "enable": false,
yapi-web | "auth": {}
yapi-web | },
yapi-web | "ldapLogin": {
yapi-web | "enable": false
yapi-web | },
yapi-web | "port": 3000
yapi-web | }
yapi-web | 等待 MongoDB 服务可用...
yapi-web | 安装 YApi 插件...
yapi-web | 尝试安装 YApi...
yapi-web | + node '--unhandled-rejections=strict' /yapi/vendors/server/install.js
yapi-web |
yapi-web | error: MongoNetworkError: Authentication failed., mongodb Authentication failed
yapi-web |
yapi-web | log: mongodb load success...
yapi-web |
yapi-web | /yapi/vendors/server/install.js:151
yapi-web | throw new Error(err.message);
yapi-web | ^
yapi-web |
yapi-web | Error: Cannot read property 'collection' of undefined
yapi-web | at /yapi/vendors/server/install.js:151:13
yapi-web | at processTicksAndRejections (internal/process/task_queues.js:97:5)
yapi-web |
yapi-web | 关闭引导服务...
yapi-web | 尝试启动 YApi...
yapi-web | log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
yapi-web | log: 服务已启动,请打开下面链接访问:
yapi-web | http://127.0.0.1:3000/
yapi-web | error: MongoNetworkError: Authentication failed., mongodb Authentication failed
yapi-web | log: mongodb load success...
yapi-web | (node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'collection' of undefined
yapi-web | at /yapi/vendors/exts/yapi-plugin-advanced-mock/server.js:24:38
yapi-web | at processTicksAndRejections (internal/process/task_queues.js:97:5)
yapi-web | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
yapi-web | (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
yapi-web | (node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'collection' of undefined
yapi-web | at /yapi/vendors/exts/yapi-plugin-statistics/server.js:12:38
yapi-web | at processTicksAndRejections (internal/process/task_queues.js:97:5)
yapi-web | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
yapi-web | (node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'collection' of undefined
yapi-web | at /yapi/vendors/exts/yapi-plugin-wiki/server.js:7:38
yapi-web | at processTicksAndRejections (internal/process/task_queues.js:97:5)
yapi-web | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
yapi-web | (node:1) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated

How to enable authentication on MongoDB through Docker?

version: '3'

services:
yapi-web:
image: jayfong/yapi:latest
container_name: yapi-web
ports:
- 40001:3000
environment:
- YAPI_ADMIN_ACCOUNT=[email protected]
- YAPI_ADMIN_PASSWORD=adm1n
- YAPI_CLOSE_REGISTER=false
- YAPI_DB_SERVERNAME=yapi-mongo
- YAPI_DB_PORT=27017
- YAPI_DB_DATABASE=yapi
- YAPI_DB_USER=root
- YAPI_DB_PASS=0000
- YAPI_DB_AUTH_SOURCE=admin
- 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
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=0000
volumes:
- ./data/db:/data/db
expose:
- 27017
restart: unless-stopped
command: mongod --auth

docker部署时,如何将插件中提供的能够在未登录yapi时可以访问的接口添加到yapi的ignoreRouter中?

yapi-plugin-ww-login为例:
yapi-plugin-ww-login插件中提供的 '/api/plugin/wx/login' 接口,在回调的时候还未登录yapi,这时候需要在未登录yapi的情况下调用该接口,yapi提供的方法是直接在如下的ignoreRouter数组中加入该接口。 docker 部署时如何将该接口添加到ignoreRouter中?
yapi /server/controllers/base.js源码 async init(ctx) 方法中:

let ignoreRouter = [
      '/api/user/login_by_token',
      '/api/user/login',
      '/api/user/reg',
      '/api/user/status',
      '/api/user/logout',
      '/api/user/avatar',
      '/api/user/login_by_ldap',
      '/api/plugin/wx/login'
    ]

插件安装

你这个进入docker 内以后没有yapi 命令,怎么安装插件呢?

K8S部署yapi,通过环境变量替换YAPI_PLUGINS报错

K8S部署yapi,通过环境变量替换YAPI_PLUGINS报错
覆盖其他配置没有问题,YAPI_PLUGINS报错

配置: YAPI_PLUGINS: [{"name":"gitlab","options":{}}]

报错如下:
undefined:1
[map[name:gitlab options:map[]]]
^

SyntaxError: Unexpected token m in JSON at position 1
at JSON.parse ()
at Function.extractConfigFromEnv (/yapi/vendors/start.js:175:40)
at Function.extractConfig (/yapi/vendors/start.js:213:44)
at new Main (/yapi/vendors/start.js:295:36)
at Object. (/yapi/vendors/start.js:370:1)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)

求大佬看下

配置插件“yapi-plugin-auto-test”重启服务未生效

在docker-compose.yml插件yapi-plugin-auto-test配置后,重启服务后日志中有报错,看不出来插件yapi-plugin-auto-test是否已安装成功,实际访问yapi平台在分组的项目导航栏中看不到自动化测试标签,拜托大神帮看看。
日志信息:

yapi-web      | 安装 YApi 插件...
yapi-web      | 尝试安装 YApi...
yapi-web      | + 
yapi-web      | node
yapi-web      |  '--unhandled-rejections=strict'
yapi-web      |  /yapi/vendors/server/install.js
yapi-web      | 
yapi-web      | 
yapi-web      | /yapi/vendors/server/install.js:15
yapi-web      |     throw new Error(
yapi-web      |     ^
yapi-web      | 
yapi-web      | Error: init.lock文件已存在,请确认您是否已安装。如果需要重新安装,请删掉init.lock文件
yapi-web      |     at install (/yapi/vendors/server/install.js:15:11)
yapi-web      |     at Object.<anonymous> (/yapi/vendors/server/install.js:155:1)
yapi-web      |     at Module._compile (internal/modules/cjs/loader.js:1133:30)
yapi-web      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
yapi-web      |     at Module.load (internal/modules/cjs/loader.js:977:32)
yapi-web      |     at Function.Module._load (internal/modules/cjs/loader.js:877:14)
yapi-web      |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
yapi-web      |     at internal/main/run_main_module.js:18:47
yapi-web      | 
yapi-web      | 关闭引导服务...
yapi-web      | 尝试启动 YApi...
yapi-web      | log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
yapi-web      | log: 服务已启动,请打开下面链接访问: 
yapi-web      | http://127.0.0.1:3000/

配置内容:
environment:
- YAPI_ADMIN_ACCOUNT=[email protected]
- YAPI_ADMIN_PASSWORD=123456
- 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_NPM_REGISTRY=https://registry.npm.taobao.org
- YAPI_PLUGINS=[{"name":"auto-test","options":"options":{}}]


默认配置无法注册新用户

docker-compose.yml中默认关闭了用户注册, 但是初始admin账号并没有创建用户的页面, 导致无法添加新用户

部署后一直提示等待mongodb服务

我的配置:
version: '3'

services:
yapi-web:
image: jayfong/yapi:latest
container_name: yapi-web
ports:
- 40001:3000
environment:
- YAPI_ADMIN_ACCOUNT=
- YAPI_ADMIN_PASSWORD=
- YAPI_CLOSE_REGISTER=true
- YAPI_DB_SERVERNAME=yapi-mongo
- YAPI_DB_PORT=27017
- YAPI_DB_DATABASE=yapi
- YAPI_DB_USER=admin
- YAPI_DB_PASS=admin
- 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

部署后运行docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
753046c7b5ca jayfong/yapi:latest "docker-entrypoint.s…" 17 seconds ago Up 15 seconds 0.0.0.0:40001->3000/tcp yapi-web
ad183c729ef6 mongo:latest "docker-entrypoint.s…" 28 minutes ago Restarting (14) 38 seconds ago yapi-mongo

按照文档一步步来的,请教一下接下来该怎么操作呢?

yapi-web启动失败了

我的配置文件
`version: '3'

services:
yapi-web:
image: jayfong/yapi:latest
container_name: yapi-web
ports:
- 40001:3000
environment:
- YAPI_ADMIN_ACCOUNT=[email protected]
- 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=false
- YAPI_PLUGINS=[{"name":"add-user"}]
- YAPI_NPM_REGISTRY=https://registry.npm.taobao.org
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
`

image

安装yapi-x谷歌插件后,仍无法上传文件

版本是1.9.2,修改 YApi 源码,删除文件 client/components/Postman/Postman.js 的第 875 行,然后将它下面代码的注释取消掉即可!然后重启了Yapi,但是上传文件接口仍展示因Chrome最新版安全策略限制,不再支持文件上传

前端刷新问题

求助
首先感谢提供本docker,一直使用稳定
近一个月发现界面刷新有问题,使系统近乎无法使用了。

环境:
迁移过服务器,现在系统 cent8,本docker正常运行和升级

问题:
界面刷新问题:例如在浏览器A创建一个接口和分组,还是停留在原状态,界面不显示新的数据,需要更换浏览器B登录,才展示出来新的数据,然后在浏览器B创建数据,也有同样问题,需要过很长时间刷新数据才更新。这个现象在多个浏览器和多个使用者处都有

新问题。。 @fjc0k

新问题。。 @fjc0k

启动引导服务...
写入配置...
{
  "plugins": [
    {
      "name": "add-user",
      "options": {}
    }
  ],
  "adminAccount": "**",
  "adminPassword": "**",
  "closeRegister": false,
  "port": 3000,
  "db": {
    "DATABASE": "yapi",
    "user": "**",
    "pass": "**",
    "connectString": "mongodb+srv://**:**@mongo-cluster1-rs0.psmdb.svc.cluster.local/yapi?replicaSet=rs0&ssl=false&slaveOk=true"
  },
  "mail": {
    "enable": false,
    "auth": {}
  },
  "ldapLogin": {
    "enable": false
  }
}
等待 MongoDB 服务可用...
安装 YApi 插件...
尝试安装 YApi...
+ node '--unhandled-rejections=strict' /yapi/vendors/server/install.js


/yapi/vendors/node_modules/mongoose/lib/error/validation.js:31
    Error.captureStackTrace(this);
          ^

Error [ValidationError]: user validation failed: username: Path `username` is required.
    at ValidationError.inspect (/yapi/vendors/node_modules/mongoose/lib/error/validation.js:61:24)
    at formatValue (internal/util/inspect.js:703:31)
    at inspect (internal/util/inspect.js:272:10)
    at afterInspector (internal/errors.js:681:14)
    at processPromiseRejections (internal/process/promises.js:194:9)
    at processTicksAndRejections (internal/process/task_queues.js:98:32) {
  errors: {
    username: MongooseError [ValidatorError]: Path `username` is required.
        at new ValidatorError (/yapi/vendors/node_modules/mongoose/lib/error/validator.js:29:11)
        at validate (/yapi/vendors/node_modules/mongoose/lib/schematype.js:1055:13)
        at /yapi/vendors/node_modules/mongoose/lib/schematype.js:1109:11
        at Array.forEach (<anonymous>)
        at SchemaString.SchemaType.doValidate (/yapi/vendors/node_modules/mongoose/lib/schematype.js:1064:14)
        at /yapi/vendors/node_modules/mongoose/lib/document.js:2190:9
        at processTicksAndRejections (internal/process/task_queues.js:79:11) {
      properties: [Object],
      kind: 'required',
      path: 'username',
      value: '',
      reason: undefined,
      [Symbol(mongoose:validatorError)]: true
    }
  },
  _message: 'user validation failed'
}

关闭引导服务...
尝试启动 YApi...
log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
log: 服务已启动,请打开下面链接访问: 
http://127.0.0.1:3000/
log: mongodb load success...

Originally posted by @airclear in #41 (comment)

docker 打包失败

兄弟,1.8.5版本的打包失败了

npm ERR! Unexpected token < in JSON at position 0 while parsing near '<!DOCTYPE html>
npm ERR! <he...'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-12-30T03_45_56_591Z-debug.log
The command '/bin/bash -c npm install node-sass react-dnd react-dnd-html5-backend --package-lock-only' returned a non-zero code: 1

知道是啥问题吗?

replicaSet集群配置一直不通

我们mongodb集群使用的是replicaSet的方式,使用镜像1.9.2运行,一直卡在“等待mongodb可用“步骤

容器打印日志如下:

启动引导服务...
写入配置...
{
  "plugins": [
    {
      "name": "add-user",
      "options": {}
    }
  ],
  "adminAccount": "**",
  "adminPassword": "**",
  "closeRegister": false,
  "port": 3000,
  "db": {
    "DATABASE": "yapi",
    "user": "**",
    "pass": "**",
    "connectString": "mongodb://**:**@mongo-cluster1-rs0.psmdb.svc.cluster.local:27017/yapi?replicaSet=rs0&ssl=false",
    "options": {
      "replset": {
        "rs_name": "rs0"
      }
    }
  },
  "mail": {
    "enable": false,
    "auth": {}
  },
  "ldapLogin": {
    "enable": false
  }
}
等待 MongoDB 服务可用...

加载auth2插件, 授权后显示请登录

oauth2插件地址

配置为:

{
      "name": "auth2",
      "options": {
        "type": "oauth2",
        "clientId": "3",
        "clientSecret": "6HHjAGud4I11ZCjC2vlhC84HwzE7kn7nbtBlfnpR",
        "authServer": "http://ms_passport.test",
        "authPath": "/oauth/authorize",
        "tokenPath": "/oauth/token",
        "infoPath": "/api/user",
        "redirectUri": "http://192.168.0.200:40001/api/plugin/oauth2/callback",
        "userKey": "name",
        "emailKey": "email",
        "buttonName": "授权登录",
        "authArgs": {
          //"response_type": "code"
        }
      }
    }

完了之后响应

{
"errcode": 40011,
"errmsg": "请登录...",
"data": null
}

请问是哪里弄错了呢, 怎么才能正常授权通过呢, 授权采用的标准oauth2, 辛苦大佬

然后还想问下 怎么进入容器里边呢
我现在是docker exec -it yapi-web [这里不知道可以填啥]

docker-compose restart yapi-web,查看日志配置还是之前的并且会抛出Error初始化管理员账号失败

抛出异常的日志是这样的:
/yapi/vendors/server/install.js:146
yapi-web | throw new Error(初始化管理员账号 "${yapi.WEBCONFIG.adminAccount}" 失败, ${err.message}); // eslint-disable-line
yapi-web | ^
yapi-web |
yapi-web | Error: 初始化管理员账号 "[email protected]" 失败, E11000 duplicate key error collection: yapi.user index: email_1 dup key: {email: "[email protected]" }
yapi-web | at /yapi/vendors/server/install.js:146:17
yapi-web | at processTicksAndRejections (internal/process/task_queues.js:97:5)

创建yapi失败

YApi 正在启动...
启动引导服务...
写入配置...

{
  "adminAccount": "[email protected]",
  "db": {
    "servername": "yapi-mongo",
    "port": 27017,
    "DATABASE": "yapi",
    "user": "mongo",
    "pass": "admin"
  },
  "mail": {
    "enable": false,
    "auth": {}
  },
  "ldapLogin": {
    "enable": false
  },
  "closeRegister": true,
  "plugins": [
    {
      "name": "add-user"
    },
    {
      "name": "webhook"
    },
    {
      "name": "add-user"
    },
    {
      "name": "webhook"
    }
  ],
  "adminPassword": "admin",
  "port": 3000
}

等待 MongoDB 服务可用...
安装 YApi 插件...

  • cd /yapi/vendors
  • npm install yapi-plugin-add-user yapi-plugin-webhook yapi-plugin-add-user yapi-plugin-webhook --no-audit

npm
WARN [email protected] requires a peer of mongoose@^4.1.12 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm
WARN [email protected] requires a peer of jquery@>=1.8.0 but none is installed. You must install peer dependencies yourself.
npm WARN
[email protected] requires a peer of react@^0.14.0 || ^15.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-dom@^0.14.0 || ^15.0.1 but none is installed. You must install peer dependencies yourself.

1 package is looking for funding
run npm fund for details

  • npm run build-client

[email protected] build-client /yapi/vendors
NODE_ENV=production ykit pack -m

--------------------- YKIT EMITTED ASSETS ---------------------

[ykit] - [email protected] - 165.17 KB

[ykit] - [email protected] - 713 Bytes

[ykit] - [email protected] - 373.47 KB

[ykit] - [email protected] - 521.36 KB

[ykit] - [email protected] - 735.40 KB

[ykit] - [email protected] - 4957.19 KB

[info] Bundling Finishes in 92s.

尝试安装 YApi...

一直停在尝试安装

运行报错

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 10)

从1.8.5升级到了1.8.8,数据丢失了

按照文档升级,执行了docker-compose pull yapi-web, down , up,结果以前的数据全没了,查看docker log如下。

#--------------------------------------------------------------------

#--------------------------------------------------------------------
查了一下命令,docker-compose down会删除现有的数据啊?这里应该执行docker-compose stop吧????

Can not change yapi-web port

I want to change yapi-web port since the default port 40001 is not friendly.

What I did is modify the "ports" value under "yapi-web" in docker-composer.yml file:

services:
yapi-web:
image: jayfong/yapi:latest
container_name: yapi-web
ports:
- 3000:3000
...

It is supposed to be available from remote by visiting url: http://SERVER-IP:3000/ ,
but is unavailable even though I restarted it ( docker-compose restart yapi-web ) !

So,what is the right way to change the yapi-web port?

Thanks a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.