1、Github介绍
https://github.com/thx/rap2-delos
2、安装Docker环境
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce
systemctl enable docker
systemctl start docker
yum install -y bash-completion
source /usr/share/bash-completion/bash_completion
source /usr/share/bash-completion/completions/docker
curl -L "https://github.com/docker/compose/releases/download/v2.9.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
3、配置YML
mkdir -p /opt/rap && cd /opt/rap
vim docker-compose.yml
写入下面的配置文件
version: "3"services:dolores:image: rapteam/rap2-dolores:latestports:- 3000:38081networks:- rap2-networkdelos:image: rapteam/rap2-delos:latestports:- 38080:38080environment:- SERVE_PORT=38080- MYSQL_URL=mysql- MYSQL_PORT=3306- MYSQL_ROOT_PASSWORD=hk1238888 # 设置 root 用户的密码- MYSQL_SCHEMA=rap2- REDIS_URL=redis- REDIS_PORT=6379- NODE_ENV=productioncommand: /bin/sh -c 'node dispatch.js'depends_on:- redis- mysqlnetworks:- rap2-networkredis:image: redis:4networks:- rap2-networkmysql:image: mysql:5.7volumes:- "./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=0environment:MYSQL_ALLOW_EMPTY_PASSWORD: "true"MYSQL_DATABASE: "rap2"networks:- rap2-networknetworks:rap2-network:
4、创建名为rap2-network的Docker网络
docker network create rap2-network
5、拉取镜像并启动
cd /opt/rap
docker-compose up -d
docker ps
启动后,第一次运行需要手动初始化mysql数据库
注意: 只有第一次该这样做
docker-compose exec delos node scripts/init
执行之后的结果
6、部署成功后访问
http://localhost:3000 # 前端(可自定义端口号)
http://localhost:38080 # 后端