rap2是阿里妈妈前端团队出品的开源接口管理工具RAP,目前是第二版,他的优点是既可以方便管理一整套标准的接口文档,又能够提供mockjs数据。
git地址:https://github.com/thx/rap2-delos
gitee地址:https://gitee.com/zuiyuewentian/rap2-delos.git
安装步骤
本地环境要求
1.安装 Docker 以及 Docker Compose
2.拉取rap2项目到本地任意目录(注:项目中已包含redis,mysql)
> git clone https://gitee.com/zuiyuewentian/rap2-delos.git
3.进入项目,修改docker-compose.yml文件,个人根据需要修改,我这里直接使用项目中的redis和mysql,为了不和本地冲突,改了映射端口。
# mail@dongguochao.com
# llitfkitfk@gmail.com
# chibing.fy@alibaba-inc.com
version: "3"
services:
# frontend
dolores:
image: rapteam/rap2-dolores:latest
ports:
#冒号前可以自定义前端端口号,冒号后不要动
- 4000:38081
# backend
delos:
image: rapteam/rap2-delos:latest
ports:
# 这里的配置不要改哦
- 38080:38080
environment:
- SERVE_PORT=38080
# if you have your own mysql, config it here, and disable the 'mysql' config blow
- MYSQL_URL=mysql # links will maintain /etc/hosts, just use 'container_name'
- MYSQL_PORT=3306
- MYSQL_USERNAME=root
- MYSQL_PASSWD=
- MYSQL_SCHEMA=rap2
# redis config
- REDIS_URL=redis
- REDIS_PORT=6379
# production / development
- NODE_ENV=production
###### 'sleep 30 && node scripts/init' will drop the tables
###### RUN ONLY ONCE THEN REMOVE 'sleep 30 && node scripts/init'
command: /bin/sh -c 'node dispatch.js'
# init the databases
# command: sleep 30 && node scripts/init && node dispatch.js
# without init
# command: node dispatch.js
depends_on:
- redis
- mysql
redis:
image: redis:4
ports:
- 6479:6379
# disable this if you have your own mysql
mysql:
image: mysql:5.7
# expose 33306 to client (navicat)
ports:
- 33306:3306
volumes:
# change './docker/mysql/volume' to your own path
# WARNING: without this line, your data will be lost.
- "./docker/mysql/volume:/var/lib/mysql"
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --init-connect='SET NAMES utf8mb4;' --innodb-flush-log-at-trx-commit=0
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_DATABASE: "rap2"
MYSQL_USER: "root"
MYSQL_PASSWORD: ""
4.拉取镜像并启动(注:以下命令后是在rap目录下执行)
docker-compose up -d
5.启动后,第一次运行需要手动初始化mysql数据库(注意)
docker-compose exec delos node scripts/init
6.部署成功后 访问 http://localhost:4000
关闭rap服务
docker-compose down