RAP2 是在 RAP1 基础上重做的新项目,它能给你提供方便的接口文档管理、Mock、导出等功能,包含两个组件(对应两个 Github Repository)。
rap2-delos: 后端数据 API 服务器,基于 Koa + MySQLlink (https://github.com/thx/rap2-delos)
rap2-dolores: 前端静态资源,基于 React link (https://github.com/thx/rap2-dolores)
Rap 官方服务站点,无需安装直接体验: rap2.taobao.org
mkdir /root/rap
# llitfkitfk@gmail.com
# chibing.fy@alibaba-inc.com
version: "3"
services:
# frontend
dolores:
image: rapteam/rap2-dolores:latest
ports:
#冒号前可以自定义前端端口号,冒号后不要动
- 3000: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
# 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: ""
注意mysql5.7不能通过MYSQL_USER和MYSQL_PASSWORD设置root用户,所以需要使用MYSQL_ROOT_USER和MYSQL_ROOT_PASSWORD
rap2-delos默认使用root,没有密码去登录mysql,地址是内网地址
docker-compose up -d
docker-compose exec delos node scripts/init
http://localhost:3000 # 前端(可自定义端口号)
http://localhost:38080 # 后端
docker-compose down