场景:使用 docker-compose.yml 安装RAP2的时候,往往需要链接现在已有的数据库,这时候需要将官方的配置文件稍作修改
注释1
将配置文件后面的redis和mysql全部注释
注释2
将services中的 depends_on 配置全部注释
修改处
将delos下的链接地址修改一下,如图
以下是完整的配置
# [email protected]
# [email protected]
# [email protected]
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=10.0.0.231(改成你的外部地址) # links will maintain /etc/hosts, just use 'container_name'
- MYSQL_PORT=3308
- MYSQL_USERNAME=root
- MYSQL_PASSWD=123456
- MYSQL_SCHEMA=rap2_delos_app
# redis config
- REDIS_URL=10.0.0.231(改成你的外部地址)
- 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: ""