GithubHelp home page GithubHelp logo

yunzhongzhuhuo / docker-yapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fjc0k/docker-yapi

0.0 1.0 0.0 75 KB

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

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

License: MIT License

Dockerfile 6.46% JavaScript 47.97% TypeScript 45.57%

docker-yapi's Introduction

docker-YApi

Docker 中运行 YApi

演示地址: https://docker-yapi.herokuapp.com/ (管理员账号:[email protected],管理员密码:adm1n)。仅供测试,服务每次部署都会重置,请不要将重要数据放在上面。

要求

你得确保在你的设备上安装了不是太老版本的 DockerDocker Compose

安装

首先,克隆本项目:

git clone https://github.com/fjc0k/docker-YApi.git

接下来,修改 docker-compose.ymlyapi-web 下的环境变量 YAPI_ADMIN_ACCOUNT 为你的管理员邮箱,YAPI_ADMIN_PASSWORD 为你的管理员密码。

最后,执行 docker-compose up -d 启动服务。

然后,通过 http://localhost:40001 即可访问 YApi

如何配置

为了减少二次配置,docker-YApi 新增了 adminPassword 选项以设置管理员密码。

通过 config.json 或者 config.js 配置

config.json 是 YApi 官方支持的配置文件,config.jsdocker-YApi 扩展支持的配置文件,其实就是将 JSON 数据写成了更简洁的 JavaScript 对象。

你可通过将外部的 config.jsonconfig.js 配置文件映射进容器内部来使用它们:

./config.json:/yapi/config.json
./config.js:/yapi/config.js

通过环境变量配置

通过环境变量配置的选项会覆盖通过 config.json 或者 config.js 配置的选项。

基础配置

环境变量名称 类型 说明 示例
YAPI_ADMIN_ACCOUNT string 管理员账号(邮箱) [email protected]
YAPI_ADMIN_PASSWORD string 管理员密码 adm1n
YAPI_CLOSE_REGISTER boolean 是否关闭注册,关闭注册后可通过插件 yapi-plugin-add-user 新增用户 true
YAPI_NPM_REGISTRY string npm 源,目前仅在安装插件时使用,默认官方源,国内可以设为淘宝源加速 https://registry.npm.taobao.org

数据库配置

环境变量名称 类型 说明 示例
YAPI_DB_SERVERNAME string MongoDB 服务地址 yapi-mongo
YAPI_DB_PORT number MongoDB 服务端口 27017
YAPI_DB_DATABASE string 使用的 MongoDB 数据库 yapi
YAPI_DB_USER string 登录 MongoDB 服务的用户名 root
YAPI_DB_PASS string 登录 MongoDB 服务的用户密码 r00t
YAPI_DB_AUTH_SOURCE string MongoDB 身份认证所用库 admin
YAPI_DB_CONNECT_STRING string 使用 MongoDB 集群时配置 mongodb://127.0.0.100:8418,127.0.0.101:8418/yapidb?slaveOk=true
YAPI_DB_OPTIONS json Mongoose 连接 MongoDB 服务时的额外选项,一般不用设置。请参考: Mongoose.prototype.connect() {}

邮件配置

环境变量名称 类型 说明 示例
YAPI_MAIL_ENABLE boolean 是否启用 true
YAPI_MAIL_HOST string 邮件服务地址 smtp.163.com
YAPI_MAIL_PORT number 邮件服务端口 465
YAPI_MAIL_FROM string 发送人邮箱 [email protected]
YAPI_MAIL_AUTH_USER string 登录邮件服务的用户名 [email protected]
YAPI_MAIL_AUTH_PASS string 登录邮件服务的用户密码 f00bar
YAPI_MAIL_OPTIONS json 传递给 Nodemailer 的额外选项,一般不用设置。请参考:Nodemailer > SMTP transport {"tls":{"rejectUnauthorized":false}}

LDAP 登录配置

点击查看 YApi 仓库下 LDAP 相关的 issues 👉

环境变量名称 类型 说明 示例
YAPI_LDAP_LOGIN_ENABLE boolean 是否启用 true
YAPI_LDAP_LOGIN_SERVER string LDAP 服务地址 ldap://ldap.foo.bar
YAPI_LDAP_LOGIN_BASE_DN string 登录 LDAP 服务的用户名 cn=admin,dc=foo,dc=bar
YAPI_LDAP_LOGIN_BIND_PASSWORD string 登录 LDAP 服务的用户密码 f00bar
YAPI_LDAP_LOGIN_SEARCH_DN string 查询用户数据的路径 ou=users,dc=foo,dc=bar
YAPI_LDAP_LOGIN_SEARCH_STANDARD string 支持两种值:
1、前端登录账号对应的查询字段,如:mailuid 等;
2、自定义查询条件,其中 %s 会被前端登录账号替换,如:&(objectClass=user)(cn=%s)
-
YAPI_LDAP_LOGIN_EMAIL_POSTFIX string 登录邮箱后缀 @163.com
YAPI_LDAP_LOGIN_EMAIL_KEY string LDAP 数据库存储用户邮箱的字段 mail
YAPI_LDAP_LOGIN_USERNAME_KEY string LDAP 数据库存储用户名的字段 name

插件配置

环境变量名称 类型 说明 示例
YAPI_PLUGINS json 要使用的插件列表。点击查看开源 YApi 插件列表→

配置项数据格式:
{
"name": "插件名称",
"options": "插件配置"
}

注意:
安装插件会运行 YApi 自带的打包命令,其内存消耗较大,因此,在安装插件时,物理机可用内存最好大于 1GB,否则,易出现内存溢出错误,导致插件安装失败。
[{"name":"add-user"},{"name":"gitlab","options":{}}]

如何重启

若你修改了配置,务必重启应用才能生效:

docker-compose restart yapi-web

如何升级

YApi 有更新,本项目应会尽快跟进,之后,你可使用以下命令升级:

docker-compose pull yapi-web \
  && docker-compose down \
  && docker-compose up -d

升级不会对原有数据造成任何影响!

查看日志

如果出现意外情况,你可通过以下命令查看运行日志:

docker-compose logs yapi-web

如何迁移

直接打包整个目录去新的服务器即可。

许可

Jay Fong © MIT

docker-yapi's People

Contributors

fjc0k avatar

Watchers

James Cloos avatar

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.