ryan-miao / docker-yapi Goto Github PK
View Code? Open in Web Editor NEWDocker build and run yapi as service
Docker build and run yapi as service
当前安装版本: 1.12.0
连接数据库成功!
开始下载平台文件压缩包...
http://registry.npm.taobao.org/yapi-vendor/download/yapi-vendor-1.12.0.tgz
部署文件完成,正在安装依赖库...
npm ERR! code CERT_HAS_EXPIRED npm ERR!
errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/ajv failed, reason: certificate has expired
npm
ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2024-03-05T18_22_18_520Z-debug.log
依赖库安装完成,正在初始化数据库mongodb...
[email protected] install-server /my-yapi/vendors > node server/install.js
Error: internal/modules/cjs/loader.js:818 throw err; ^ Error: Cannot find module 'fs-extra' Require stack: - /my-yapi/vendors/server/install.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15) at Function.Module._load (internal/modules/cjs/loader.js:667:27) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/my-yapi/vendors/server/install.js:1:12) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) { code: 'MODULE_NOT_FOUND', requireStack: [ '/my-yapi/vendors/server/install.js' ] }
16:32:02 /usr/local/docker-yapi # docker-compose up
WARNING: Found orphan containers (docker-yapi_mongo_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Recreating docker-yapi_yapi_1 ... done
Attaching to docker-yapi_yapi_1
yapi_1 | internal/modules/cjs/loader.js:818
yapi_1 | throw err;
yapi_1 | ^
yapi_1 |
yapi_1 | Error: Cannot find module '/my-yapi/vendors/server/app.js'
yapi_1 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
yapi_1 | at Function.Module._load (internal/modules/cjs/loader.js:667:27)
yapi_1 | at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
yapi_1 | at internal/main/run_main_module.js:17:47 {
yapi_1 | code: 'MODULE_NOT_FOUND',
yapi_1 | requireStack: []
yapi_1 | }
docker-yapi_yapi_1 exited with code 1
以为是1.9.2版本的问题,换成了1.9.1重新安装后,打开ip:3000界面后,还是不能登录 , 点了登录一点反映也没有, 注册也没反应.
internal/modules/cjs/loader.js:818
throw err;
^
Error: Cannot find module '/my-yapi/vendors/server/app.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
镜像build了好多次, 模块找不到
如题,查看日志 报
error: MongoError: Authentication failed., mongodb Authentication failed
log: mongodb load success...
(node:6) UnhandledPromiseRejectionWarning: Error: Cannot read property 'collection' of undefined
at /api/vendors/server/install.js:151:13
at processTicksAndRejections (internal/process/task_queues.js:86:5)
(node:6) 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(). (rejection id: 1)
(node:6) [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的全部日志
$ docker logs -f 54459a7fc202
log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
log: 服务已启动,请打开下面链接访问:
http://127.0.0.1:3000/
error: MongoNetworkError: connect ECONNREFUSED 172.19.0.2:27017, mongodb Authentication failed
log: mongodb load success...
(node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'collection' of undefined
at /my-yapi/vendors/exts/yapi-plugin-advanced-mock/server.js:24:38
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(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)
(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.
(node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'collection' of undefined
at /my-yapi/vendors/exts/yapi-plugin-statistics/server.js:12:38
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(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)
(node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'collection' of undefined
at /my-yapi/vendors/exts/yapi-plugin-wiki/server.js:7:38
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(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)
(node:1) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
请问需要怎么样升级yapi呢,更换了version似乎不起作用,1.10.2的version还是配置到了1.9.1
Error: 连接数据库失败,failed to connect to server [127.0.0.1:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
想问下这个是为什么?
yapi_1 | 在浏览器打开 http://0.0.0.0:9090 访问。非本地服务器,请将 0.0.0.0 替换成指定的域名或ip
yapi_1 | (node:1) UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND yapi.demo.qunar.com
yapi_1 | at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)
yapi_1 | (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_1 | (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_1 | 当前安装版本: 1.9.2
yapi_1 | Error: 连接数据库失败, failed to connect to server [127.0.0.1:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
yapi_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1145:16) {
yapi_1 | name: 'MongoError'
yapi_1 | }]
`依赖库安装完成,正在初始化数据库mongodb...
[email protected] install-server /my-yapi/vendors > node server/install.js
Error: /my-yapi/vendors/server/utils/commons.js:25 jsf.extend('mock', function () { ^ TypeError: jsf.extend is not a function at Object. (/my-yapi/vendors/server/utils/commons.js:25:5) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/my-yapi/vendors/server/install.js:3:17) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) at internal/main/run_main_module.js:17:47
`
导致build镜像的时候报错, 错误提示不太友好
Step 4/16 : ADD yapi.tgz /home/
ADD failed: stat /var/lib/docker/tmp/docker-builder468713448/yapi.tgz: no such file or directory
Error response from daemon: No such image: yapi:latest
Building yapi
Step 1/4 : FROM node:12-alpine
---> 057fa4cc38c2
Step 2/4 : COPY repositories /etc/apk/repositories
---> Using cache
---> 3c404293437f
Step 3/4 : RUN npm install -g yapi-cli --registry https://registry.npm.taobao.org
---> Running in 1b16396feb05
如果用docker-compose重启时会报错
log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
log: 服务已启动,请打开下面链接访问:
http://127.0.0.1:3000/
error: MongoNetworkError: connect ECONNREFUSED 172.20.0.2:27017, mongodb Authentication failed
log: mongodb load success...
(node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'collection' of undefined
at /my-yapi/vendors/exts/yapi-plugin-advanced-mock/server.js:24:38
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(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)
(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.
(node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'collection' of undefined
at /my-yapi/vendors/exts/yapi-plugin-statistics/server.js:12:38
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(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)
(node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'collection' of undefined
at /my-yapi/vendors/exts/yapi-plugin-wiki/server.js:7:38
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(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)
(node:1) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
这个报错,是因为mongo并未启动完成, yapi连接太快, 连接不上.
解决办法:
等几分钟后等mongo启动完成后,再次重启yapi-web容器即可
打开localhost:9090后,没看到有地方可以配置
1、打开数据库认证
2、输入数据库用户名: yapi(mongo配置的用户名, 见mongo-conf/init-mongo.js)
3、输入密码: yapi123456(mongo配置的密码, 见mongo-conf/init-mongo.js)
没有做以上步骤,导致部署失败,看报错是mongodb认证失败
依赖库安装完成,正在初始化数据库mongodb...
[email protected] install-server /my-yapi/vendors > node server/install.js
log: mongodb load success...
Error: (node:209) UnhandledPromiseRejectionWarning: MongoError: command createIndexes requires authentication at Connection. (/my-yapi/vendors/node_modules/mongoose/node_modules/mongodb/lib/core/connection/pool.js:466:61) at Connection.emit (events.js:314:20) at processMessage (/my-yapi/vendors/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connection.js:364:10) at Socket. (/my-yapi/vendors/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connection.js:533:15) at Socket.emit (events.js:314:20) at addChunk (_stream_readable.js:298:12) at readableAddChunk (_stream_readable.js:273:9) at Socket.Readable.push (_stream_readable.js:214:10) at TCP.onStreamRead (internal/stream_base_commons.js:188:23) (node:209) 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) (node:209) [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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.