介绍
给大家推荐一个开源接口管理平台YApi,众多互联网大厂都在使用

YApi 的一些客户:百度,阿里巴巴,腾讯,今日头条等

GitHub地址:https://github.com/YMFE/yapi

github上有本地安装的教程,因为docker安装比较方便,因此官方推荐了如下docker安装教程,当然docker镜像不是官方做的。建议配置阿里云Docker镜像仓库,下载起来比较快

使用 Docker 构建 YApi
1.启动 MongoDB

docker run -d --name mongo-yapi mongo
2.获取 Yapi 镜像,版本信息可在 阿里云镜像仓库 查看

docker pull registry.cn-hangzhou.aliyuncs.com/anoy/yapi
3.初始化 Yapi 数据库索引及管理员账号

docker run -it --rm
–link mongo-yapi:mongo
–entrypoint npm
–workdir /api/vendors
registry.cn-hangzhou.aliyuncs.com/anoy/yapi
run install-server
自定义配置文件挂载到目录 /api/config.json,官方自定义配置文件
https://github.com/YMFE/yapi/blob/master/config_example.json

4.启动 Yapi 服务

docker run -d
–name yapi
–link mongo-yapi:mongo
–workdir /api/vendors
-p 3000:3000
registry.cn-hangzhou.aliyuncs.com/anoy/yapi
server/app.js
使用 Yapi
访问 http://localhost:3000 登录账号 admin@admin.com,密码 ymfe.org

至此,帅气的 YApi 就可以轻松使用啦!更多文档信息,请参考

YApi 官方教程
https://hellosean1025.github.io/yapi/documents/index.html

YApi 版本更新记录
https://github.com/YMFE/yapi/blob/master/CHANGELOG.md

其他相关操作
1.关闭 YApi

docker stop yapi
2.启动YApi

docker start yapi
3.升级 YApi

1、停止并删除旧版容器

docker rm -f yapi

2、获取最新镜像

docker pull registry.cn-hangzhou.aliyuncs.com/anoy/yapi

3、启动新容器

docker run -d
–name yapi
–link mongo-yapi:mongo
–workdir /api/vendors
-p 3000:3000
registry.cn-hangzhou.aliyuncs.com/anoy/yapi
server/app.js
手动构建 YApi 镜像
1.下载 YApi 到本地

wget -o yapi.tar.gz https://github.com/YMFE/yapi/archive/v1.8.0.tar.gz
下载地址:https://github.com/YMFE/yapi/releases

2.编辑 Dockerfile

FROM node:12-alpine as builder

RUN apk add --no-cache git python make openssl tar gcc

COPY yapi.tar.gz /home

RUN cd /home && tar zxvf yapi.tar.gz && mkdir /api && mv /home/yapi-1.8.0 /api/vendors

RUN cd /api/vendors &&
npm install --production --registry https://registry.npm.taobao.org

FROM node:12-alpine

MAINTAINER 545544032@qq.com

ENV TZ=“Asia/Shanghai” HOME="/"

WORKDIR ${HOME}

COPY --from=builder /api/vendors /api/vendors

COPY config.json /api/

EXPOSE 3000

ENTRYPOINT [“node”]
3.构建镜像

docker build -t yapi .

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐