一、官网
二、Mac本地接入
1、创建网段
在Mac上:替换所有网络模式为自己定义的网段(或注释网断设置)
network_mode: "mynet"
:::info
网段设定可参考Docker网络模式--network_mode
:::
2、启动基础容器
修改minio
映射路径
-v /home/minio/data:/data改成-v /home/minio/data:/mnt/data
cd docker
docker-compose up -d mysql nginx-web redis minio
3、建表
分别建立数据库,运行以下SQL文件
DROP DATABASE IF EXISTS `ry-cloud`;
CREATE DATABASE `ry-cloud` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
USE `ry-cloud`;
:::warning
注:test.sql应在ry-cloud库内执行
:::
4、运行nacos
更改nacos的MySQL配置
# db.url.0=jdbc:mysql://127.0.0.1:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
# db.user.0=root
# db.password.0=root
db.url.0=jdbc:mysql://mysql:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
db.user.0=root
db.password.0=ruoyi123
对配置后的ruoyi-nacos
进行打包
docker build -t ruoyi/ruoyi-nacos:1.8.0 ruoyi-visual/ruoyi-nacos/.
cd docker
docker-compose up -d nacos
启动成功
进入后台页面localhost:8848/nacos/index.html
更改跟pom.xml的nacos地址
<profile>
<id>dev</id>
<properties>
<!-- 环境标识,需要与配置文件的名称相对应 -->
<profiles.active>dev</profiles.active>
<nacos.server>nacos:8848</nacos.server>
<nacos.discovery.group>DEFAULT_GROUP</nacos.discovery.group>
<nacos.config.group>DEFAULT_GROUP</nacos.config.group>
<logstash.address>127.0.0.1:4560</logstash.address>
</properties>
<activation>
<!-- 默认环境 -->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
5、更改nacos配置
将config/nacos目录下的文件依次拷贝到dev环境的nacos配置
更改数据源配置
datasource:
system-master:
# localhost --> mysql
url: jdbc:mysql://mysql:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
username: root
password: ruoyi123
gen:
url: jdbc:mysql://mysql:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
username: root
password: ruoyi123
job:
url: jdbc:mysql://mysql:3306/ry-job?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
username: root
password: ruoyi123
6、构建核心项目镜像
项目打包
mvn clean install -U -D maven.test.skip=true -P dev
构建镜像
docker build -t ruoyi/ruoyi-monitor:1.8.0 ruoyi-visual/ruoyi-monitor/.
# docker build -t ruoyi/ruoyi-nacos:1.8.0 ruoyi-visual/ruoyi-nacos/.
docker build -t ruoyi/ruoyi-seata-server:1.8.0 ruoyi-visual/ruoyi-seata-server/.
docker build -t ruoyi/ruoyi-sentinel-dashboard:1.8.0 ruoyi-visual/ruoyi-sentinel-dashboard/.
docker build -t ruoyi/ruoyi-xxl-job-admin:1.8.0 ruoyi-visual/ruoyi-xxl-job-admin/.
docker build -t ruoyi/ruoyi-gateway:1.8.0 ruoyi-gateway/.
docker build -t ruoyi/ruoyi-auth:1.8.0 ruoyi-auth/.
docker build -t ruoyi/ruoyi-system:1.8.0 ruoyi-modules/ruoyi-system/.
docker build -t ruoyi/ruoyi-gen:1.8.0 ruoyi-modules/ruoyi-gen/.
docker build -t ruoyi/ruoyi-job:1.8.0 ruoyi-modules/ruoyi-job/.
docker build -t ruoyi/ruoyi-resource:1.8.0 ruoyi-modules/ruoyi-resource/.
运行容器
cd docker
docker-compose up -d seata-server sentinel ruoyi-monitor ruoyi-xxl-job-admin
7、业务服务
cd docker
docker-compose up -d ruoyi-gateway ruoyi-auth ruoyi-system ruoyi-resource
网关测试成功(说明mysql/redis配置成功)
全部业务服务启动成功
8、启动前端项目
# 进入项目目录
cd ruoyi-ui-vue3
# 安装依赖
npm install --registry=https://registry.npmmirror.com
# 启动服务
npm run dev
# 构建生产环境 yarn build:prod
# 前端访问地址 http://localhost:80
三、Linux部署
原host网络模式
host开放防火墙
指定自定义网段