1.安装 docker、docker-compose
2.创建 /data/run/mysql/conf/my.cnf 配置文件
[mysqld]
user=mysql
default-storage-engine=INNODB
character-set-server=utf8mb6
default-time_zone = '+8:00'
sql-mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
3.创建 rap2-docker-compose.yml 文件
version: "3"
services:
# frontend
dolores:
image: rapteam/rap2-dolores:latest
container_name: docker-rap-dolores
ports:
#冒号前可以自定义前端端口号,冒号后不要动
- 3000:38081
restart: always
# backend
delos:
image: rapteam/rap2-delos:latest
container_name: docker-rap-delos
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=rap2@2022
- 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
restart: always
redis:
image: redis:6.2
container_name: docker-rap-redis-6.2
restart: always
mysql:
image: mysql:5.7
container_name: docker-rap-mysql-5.7
privileged: true #一定要设置为true,不然数据卷可能挂载不了,启动不起
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: rap2@2022 # 自己配置数据库密码
TZ: Asia/Shanghai
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--max_allowed_packet=128M
--sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO"
volumes:
- /data/run/mysql/data:/var/lib/mysql
- /data/run/mysql/conf/my.cnf:/etc/my.cnf
restart: always
4.执行 rap2-docker-compose.yml文件
docker-compose -f rap2-docker-compose.yml up -d
5.验证安装是否成功
#查看容器是否启动成功
docker ps
或者
访问 http://localhost:3000 登录 rap接口管理工具