{"id":14978990,"url":"https://github.com/fjc0k/docker-yapi","last_synced_at":"2025-05-16T13:04:27.761Z","repository":{"id":37743298,"uuid":"199180990","full_name":"fjc0k/docker-YApi","owner":"fjc0k","description":"接口管理平台 YApi 的 Docker 镜像。","archived":false,"fork":false,"pushed_at":"2023-08-16T08:49:49.000Z","size":91,"stargazers_count":1125,"open_issues_count":48,"forks_count":266,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-09T08:05:21.970Z","etag":null,"topics":["docker","docker-image","docker-yapi","yapi","yapi-docker","yapi-docker-compose"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/jayfong/yapi/tags","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fjc0k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-07-27T15:18:18.000Z","updated_at":"2025-04-08T06:47:34.000Z","dependencies_parsed_at":"2024-01-16T09:03:09.592Z","dependency_job_id":"caa1fbc7-9090-4405-a8b7-236efa256da1","html_url":"https://github.com/fjc0k/docker-YApi","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Fdocker-YApi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Fdocker-YApi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Fdocker-YApi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Fdocker-YApi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fjc0k","download_url":"https://codeload.github.com/fjc0k/docker-YApi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247999859,"owners_count":21031046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-image","docker-yapi","yapi","yapi-docker","yapi-docker-compose"],"created_at":"2024-09-24T13:58:51.599Z","updated_at":"2025-04-09T08:05:27.972Z","avatar_url":"https://github.com/fjc0k.png","language":"TypeScript","readme":"# docker-YApi\n\n在 [Docker](https://www.docker.com/) 中运行 [YApi](https://github.com/YMFE/yapi)。\n\n---\n\n演示地址： [https://dockeryapi-fjc0kb.b4a.run/](https://dockeryapi-fjc0kb.b4a.run/)\n\n管理员账号：`admin@docker.yapi`\n\n管理员密码：`adm1n`\n\n仅供测试，服务每次部署都会重置，请不要将重要数据放在上面。\n\n\u003e 演示服务所需资源由 [Back4App](https://www.back4app.com/) 免费提供。\n\n---\n\n\u003c!-- TOC depthFrom:2 --\u003e\n\n- [要求](#要求)\n- [安装](#安装)\n- [如何配置](#如何配置)\n  - [通过 config.json 或者 config.js 配置（不推荐）](#通过-configjson-或者-configjs-配置不推荐)\n  - [通过环境变量配置（推荐）](#通过环境变量配置推荐)\n    - [基础配置](#基础配置)\n    - [数据库配置](#数据库配置)\n    - [邮件配置](#邮件配置)\n    - [LDAP 登录配置](#ldap-登录配置)\n    - [插件配置](#插件配置)\n- [内置插件](#内置插件)\n- [如何重启](#如何重启)\n- [如何升级](#如何升级)\n- [查看日志](#查看日志)\n- [如何迁移](#如何迁移)\n- [play 版说明](#play-版说明)\n- [YApi 相关资源推荐](#yapi-相关资源推荐)\n- [许可](#许可)\n\n\u003c!-- /TOC --\u003e\n\n## 要求\n\n你得确保在你的设备上安装了不是太老版本的 [`Docker`](https://docs.docker.com/install/linux/docker-ce/centos/#install-docker-ce) 和 [`Docker Compose`](https://docs.docker.com/compose/install/)。\n\n## 安装\n\n首先，克隆本项目：\n\n```bash\ngit clone https://github.com/fjc0k/docker-YApi.git\n\n# 无法访问 github 的可使用国内镜像：\ngit clone https://gitee.com/fjc0k/docker-YApi.git\n```\n\n接下来，修改 `docker-compose.yml` 中 `yapi-web` 下的环境变量 `YAPI_ADMIN_ACCOUNT` 为你的管理员邮箱，`YAPI_ADMIN_PASSWORD` 为你的管理员密码。\n\n最后，执行 `docker-compose up -d` 启动服务。\n\n然后，通过 `http://localhost:40001` 即可访问 `YApi`。\n\n## 如何配置\n\n为了减少二次配置，`docker-YApi` 新增了 `adminPassword` 选项以设置管理员密码。\n\n### 通过 config.json 或者 config.js 配置（不推荐）\n\n`config.json` 是 YApi 官方支持的配置文件，`config.js` 是 `docker-YApi` 扩展支持的配置文件，其实就是将 JSON 数据写成了更简洁的 JavaScript 对象。\n\n你可通过将外部的 `config.json` 或 `config.js` 配置文件映射进容器内部来使用它们：\n\n```bash\n./config.json:/yapi/config.json\n./config.js:/yapi/config.js\n```\n\n### 通过环境变量配置（推荐）\n\n通过环境变量配置的选项会覆盖通过 `config.json` 或者 `config.js` 配置的选项。\n\n#### 基础配置\n\n| 环境变量名称        | 类型    | 说明                                                                                           | 示例                            |\n| ------------------- | ------- | ---------------------------------------------------------------------------------------------- | ------------------------------- |\n| YAPI_ADMIN_ACCOUNT  | string  | 管理员账号（邮箱）                                                                             | admin@foo.bar                   |\n| YAPI_ADMIN_PASSWORD | string  | 管理员密码                                                                                     | adm1n                           |\n| YAPI_CLOSE_REGISTER | boolean | 是否关闭注册，由于 docker-YApi 已[内置相关插件](#内置插件)，你可在关闭注册后在后台手动添加用户 | true                            |\n| YAPI_NPM_REGISTRY   | string  | npm 源，目前仅在安装插件时使用，默认官方源，国内可以设为淘宝源加速                             | https://registry.npm.taobao.org |\n\n#### 数据库配置\n\n| 环境变量名称           | 类型   | 说明                                                                                                                                                                  | 示例                                                            |\n| ---------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |\n| YAPI_DB_SERVERNAME     | string | MongoDB 服务地址                                                                                                                                                      | yapi-mongo                                                      |\n| YAPI_DB_PORT           | number | MongoDB 服务端口                                                                                                                                                      | 27017                                                           |\n| YAPI_DB_DATABASE       | string | 使用的 MongoDB 数据库                                                                                                                                                 | yapi                                                            |\n| YAPI_DB_USER           | string | 登录 MongoDB 服务的用户名                                                                                                                                             | root                                                            |\n| YAPI_DB_PASS           | string | 登录 MongoDB 服务的用户密码                                                                                                                                           | r00t                                                            |\n| YAPI_DB_AUTH_SOURCE    | string | MongoDB 身份认证所用库                                                                                                                                                | admin                                                           |\n| YAPI_DB_CONNECT_STRING | string | 使用 MongoDB 集群时配置                                                                                                                                               | mongodb://127.0.0.100:8418,127.0.0.101:8418/yapidb?slaveOk=true |\n| YAPI_DB_OPTIONS        | json   | Mongoose 连接 MongoDB 服务时的额外选项，一般不用设置。请参考: [Mongoose.prototype.connect()](https://mongoosejs.com/docs/api/mongoose.html#mongoose_Mongoose-connect) | {}                                                              |\n\n#### 邮件配置\n\n| 环境变量名称        | 类型    | 说明                                                                                                            | 示例                                 |\n| ------------------- | ------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------ |\n| YAPI_MAIL_ENABLE    | boolean | 是否启用                                                                                                        | true                                 |\n| YAPI_MAIL_HOST      | string  | 邮件服务地址                                                                                                    | smtp.163.com                         |\n| YAPI_MAIL_PORT      | number  | 邮件服务端口                                                                                                    | 465                                  |\n| YAPI_MAIL_FROM      | string  | 发送人邮箱                                                                                                      | foo@163.com                          |\n| YAPI_MAIL_AUTH_USER | string  | 登录邮件服务的用户名                                                                                            | bar@163.com                          |\n| YAPI_MAIL_AUTH_PASS | string  | 登录邮件服务的用户密码                                                                                          | f00bar                               |\n| YAPI_MAIL_OPTIONS   | json    | 传递给 Nodemailer 的额外选项，一般不用设置。请参考：[Nodemailer \u003e SMTP transport](https://nodemailer.com/smtp/) | {\"tls\":{\"rejectUnauthorized\":false}} |\n\n#### LDAP 登录配置\n\n[点击查看 YApi 仓库下 LDAP 相关的 issues 👉](https://github.com/YMFE/yapi/issues?utf8=%E2%9C%93\u0026q=ldap)\n\n| 环境变量名称                    | 类型    | 说明                                                                                                                                                             | 示例                   |\n| ------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- |\n| YAPI_LDAP_LOGIN_ENABLE          | boolean | 是否启用                                                                                                                                                         | true                   |\n| YAPI_LDAP_LOGIN_SERVER          | string  | LDAP 服务地址                                                                                                                                                    | ldap://ldap.foo.bar    |\n| YAPI_LDAP_LOGIN_BASE_DN         | string  | 登录 LDAP 服务的用户名                                                                                                                                           | cn=admin,dc=foo,dc=bar |\n| YAPI_LDAP_LOGIN_BIND_PASSWORD   | string  | 登录 LDAP 服务的用户密码                                                                                                                                         | f00bar                 |\n| YAPI_LDAP_LOGIN_SEARCH_DN       | string  | 查询用户数据的路径                                                                                                                                               | ou=users,dc=foo,dc=bar |\n| YAPI_LDAP_LOGIN_SEARCH_STANDARD | string  | 支持两种值：\u003cbr /\u003e1、前端登录账号对应的查询字段，如：`mail`、`uid` 等；\u003cbr /\u003e2、自定义查询条件，其中 `%s` 会被前端登录账号替换，如：`\u0026(objectClass=user)(cn=%s)` | -                      |\n| YAPI_LDAP_LOGIN_EMAIL_POSTFIX   | string  | 登录邮箱后缀                                                                                                                                                     | @163.com               |\n| YAPI_LDAP_LOGIN_EMAIL_KEY       | string  | LDAP 数据库存储用户邮箱的字段                                                                                                                                    | mail                   |\n| YAPI_LDAP_LOGIN_USERNAME_KEY    | string  | LDAP 数据库存储用户名的字段                                                                                                                                      | name                   |\n\n#### 插件配置\n\n| 环境变量名称 | 类型 | 说明                                                                                                                                                                                                                                                                                                                                                                                                                               | 示例                             |\n| ------------ | ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |\n| YAPI_PLUGINS | json | 要使用的插件列表。[点击查看开源 YApi 插件列表 →](https://www.npmjs.com/search?q=yapi-plugin-)\u003cbr /\u003e\u003cbr /\u003e**配置项数据格式：**\u003cbr /\u003e{\u003cbr /\u003e \"name\": \"插件名称，必须去除前缀 yapi-plugin-\",\u003cbr /\u003e \"options\": \"插件配置，没有配置则不必设置\"\u003cbr /\u003e}\u003cbr /\u003e\u003cbr /\u003e**注意：**\u003cbr /\u003e安装插件会运行 YApi 自带的打包命令，其内存消耗较大，因此，在安装插件时，物理机可用内存最好大于等于 `4GB`，否则，易出现内存溢出错误，导致插件安装失败。 | [{\"name\":\"gitlab\",\"options\":{}}] |\n\n## 内置插件\n\n为 YApi 安装插件是一件异常缓慢且易因服务器配置不够而出错的事情，因此 docker-YApi 内置了以下插件，希望能减少点不必要的麻烦：\n\n- [yapi-plugin-add-user](https://github.com/congqiu/yapi-plugin-add-user): 支持管理员直接通过邮箱添加用户。 \u003c作者: [@congqiu](https://github.com/congqiu)\u003e\n\n如果你有其他希望内置的插件，[欢迎提交 issue](https://github.com/fjc0k/docker-YApi/issues/new)。\n\n## 如何重启\n\n若你修改了配置，务必重启应用才能生效：\n\n```bash\ndocker-compose restart yapi-web\n```\n\n## 如何升级\n\n\u003cimg src=\"https://badgen.net/github/tag/YMFE/yapi?label=YApi%20%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC\"\u003e \u003cimg src=\"https://badgen.net/github/tag/fjc0k/docker-YApi?label=docker-YApi%20%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC\"\u003e\n\n若 `YApi` 有更新，本项目应会尽快跟进，之后，你可使用以下命令升级：\n\n```bash\ndocker-compose pull yapi-web \\\n  \u0026\u0026 docker-compose down \\\n  \u0026\u0026 docker-compose up -d\n```\n\n\u003e 升级不会对原有数据造成任何影响！\n\n## 查看日志\n\n如果出现意外情况，你可通过以下命令查看运行日志：\n\n```bash\ndocker-compose logs yapi-web\n```\n\n## 如何迁移\n\n直接打包整个目录去新的服务器即可。\n\n## play 版说明\n\n本项目额外提供了一个开箱即用的 play 版本（内置了数据库），你可通过它对 YApi 作一个大概的了解：\n\n```bash\n# 纯粹的\ndocker run --rm -p 40001:3000 jayfong/yapi:play\n\n# 带插件的\ndocker run --rm -p 40001:3000 -e YAPI_PLUGINS='[{\"name\":\"interface-oauth2-token\"}]' jayfong/yapi:play\n```\n\n你可在本地或 [https://labs.play-with-docker.com/](https://labs.play-with-docker.com/) 上运行上面的命令，然后打开 `http://localhost:40001` 体验 YApi。\n\n\u003e 默认的管理员账号：`admin@docker.yapi`，管理员密码：`adm1n`。\n\n## YApi 相关资源推荐\n\n- [YApi-X](https://github.com/fjc0k/YApi-X#readme)\n\n  YApi 二次开发版，进行了很多功能上的增强，原生支持 Docker 安装。\n\n- [YApi-X 浏览器插件](https://github.com/fjc0k/YApi-X/tree/master/chrome-extension#readme)\n\n  为 YApi-X 开发的浏览器跨域与文件上传插件，同时支持 YApi 官方版。\n\n- [YApi to TypeScript](https://github.com/fjc0k/yapi-to-typescript#readme)\n\n  根据 YApi 的接口定义生成 TypeScript 的接口类型及其请求函数代码，同时支持生成 React Hooks 代码。\n\n## 许可\n\nJay Fong © MIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjc0k%2Fdocker-yapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffjc0k%2Fdocker-yapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjc0k%2Fdocker-yapi/lists"}