[2025-01-03] 添加yapi部署指南
All checks were successful
Publish to Confluence / confluence (push) Successful in 37s

This commit is contained in:
liuxiaohua 2025-01-03 14:53:33 +08:00
parent bb5c415153
commit 474861b075

View File

@ -59,7 +59,7 @@ cp vendors/config_cp.json ./config.json
```dockerfile ```dockerfile
FROM node:12-alpine3.15 FROM node:12-alpine3.15
ENV TZ="Asia/Shanghai" ENV TZ="Asia/Shanghai"
# 使用阿里云镜像 #-使用阿里云镜像
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
WORKDIR /yapi/vendors WORKDIR /yapi/vendors
COPY . /yapi/vendors/ COPY . /yapi/vendors/
@ -68,10 +68,10 @@ RUN mv /yapi/vendors/config_cp.json /yapi/config.json
RUN npm config set registry https://registry.npmmirror.com RUN npm config set registry https://registry.npmmirror.com
# 构建 yapi #-构建 yapi
RUN apk add --no-cache wget python2 make g++ && cd /yapi/vendors && npm set strict-ssl false && npm install --production --registry https://registry.npmmirror.com RUN apk add --no-cache wget python2 make g++ && cd /yapi/vendors && npm set strict-ssl false && npm install --production --registry https://registry.npmmirror.com
# 插件安装 #-插件安装
RUN npm install -g ykit --registry https://registry.npmmirror.com RUN npm install -g ykit --registry https://registry.npmmirror.com
RUN npm install yapi-plugin-kc-oidc --registry https://registry.npmmirror.com RUN npm install yapi-plugin-kc-oidc --registry https://registry.npmmirror.com
@ -107,7 +107,7 @@ docker run -d --rm \
-v $PWD/config.json:/yapi/config.json \ -v $PWD/config.json:/yapi/config.json \
qifu-base-yapi:1.0.0 \ qifu-base-yapi:1.0.0 \
server/install.js server/install.js
# 初始化管理员账号在上面的 config.json 配置中 hexiaohei1024@gmail.com初始密码是 ymfe.org可以登录后进入个人中心修改 #-初始化管理员账号在上面的 config.json 配置中 hexiaohei1024@gmail.com初始密码是 ymfe.org可以登录后进入个人中心修改
``` ```
### 启动 YApi ### 启动 YApi
@ -148,26 +148,26 @@ docker run -d \
### YAPI 安装启动 ### YAPI 安装启动
```shell ```shell
# 配置淘宝镜像 #-配置淘宝镜像
npm config set registry https://registry.npmmirror.com npm config set registry https://registry.npmmirror.com
# 安装windows构建工具, windows 才需要 #-安装windows构建工具, windows 才需要
##npm install --g --production windows-build-tools ##-npm install --g --production windows-build-tools
# 构建 yapi #-构建 yapi
mkdir yapi mkdir yapi
# 进入文件夹 #-进入文件夹
cd yapi cd yapi
# 或者下载 zip 包解压到 vendors 目录clone 整个仓库大概 140+ M可以通过 `git clone --depth=1 https://github.com/YMFE/yapi.git vendors` 命令减少,大概 10+ M #-或者下载 zip 包解压到 vendors 目录clone 整个仓库大概 140+ M可以通过 `git clone --depth=1 https://github.com/YMFE/yapi.git vendors` 命令减少,大概 10+ M
git clone https://github.com/YMFE/yapi.git vendors git clone https://github.com/YMFE/yapi.git vendors
# 复制完成后请修改相关配置 #-复制完成后请修改相关配置
cp vendors/config_example.json ./config.json cp vendors/config_example.json ./config.json
cd vendors cd vendors
npm install --production --registry https://registry.npmmirror.com npm install --production --registry https://registry.npmmirror.com
# npm install --production --unsafe-perm=true --allow-root --registry https://registry.npmmirror.com #-npm install --production --unsafe-perm=true --allow-root --registry https://registry.npmmirror.com
# 安装程序会初始化数据库索引和管理员账号,管理员账号名可在 config.json 配置 #-安装程序会初始化数据库索引和管理员账号,管理员账号名可在 config.json 配置
npm run install-server npm run install-server
# 启动服务器后,请访问 127.0.0.1:{config.json配置的端口},初次运行会有个编译的过程,请耐心等候 #-启动服务器后,请访问 127.0.0.1:{config.json配置的端口},初次运行会有个编译的过程,请耐心等候
node server/app.js node server/app.js
``` ```
@ -182,30 +182,30 @@ node server/app.js
- 执行编译 - 执行编译
```shell ```shell
# 2.0 进入工作目录 #-2.0 进入工作目录
cd yapi/vendors cd yapi/vendors
# 2.1 安装所有依赖包 #-2.1 安装所有依赖包
## 安装过程中可能出现node-sass报错替换到新的版本就可解决比如我将"node-sass": "^4.9.0" 替换成了 "node-sass": "^4.14.0" ##-安装过程中可能出现node-sass报错替换到新的版本就可解决比如我将"node-sass": "^4.9.0" 替换成了 "node-sass": "^4.14.0"
## sed -i s/'"node-sass": "^4.9.0"'/'"node-sass": "^4.14.0"'/ package.json ##-sed -i s/'"node-sass": "^4.9.0"'/'"node-sass": "^4.14.0"'/ package.json
npm install --registry https://registry.npmmirror.com npm install --registry https://registry.npmmirror.com
# 2.2 安装ykit工具 #-2.2 安装ykit工具
npm install -g ykit --registry https://registry.npmmirror.com npm install -g ykit --registry https://registry.npmmirror.com
# 2.3 安装yapi-plugin-kc-oidc #-2.3 安装yapi-plugin-kc-oidc
npm install yapi-plugin-kc-oidc --registry https://registry.npmmirror.com npm install yapi-plugin-kc-oidc --registry https://registry.npmmirror.com
## 或者不用npm安装自己去git clone代码 ##-或者不用npm安装自己去git clone代码
## cd node_modules && git clone --depth 1 https://gitee.com/joshu/yapi-plugin-kc-oidc.git ##-cd node_modules && git clone --depth 1 https://gitee.com/joshu/yapi-plugin-kc-oidc.git
# 2.4 开始编译 #-2.4 开始编译
## cd yapi/vendors ##-cd yapi/vendors
## linux ##-linux
npm run build-client npm run build-client
## windows ##-windows
### set NODE_ENV=production ###-set NODE_ENV=production
### ykit pack -m ###-ykit pack -m
``` ```
## 配置文件 ## 配置文件