Docker一键启动微服务前后端
1. 下载项目
git clone https://github.com/jeecgboot/JeecgBoot.git
2. 编译后台项目
进入后台
cd JeecgBoot/jeecg-boot
编译
mvn clean install -Pdev,SpringCloud
3. 修改前端配置
配置文件:jeecgboot-vue3/.env.production
VITE_GLOB_DOMAIN_URL=http://jeecg-boot-gateway:9999
重要提醒:
- 本地测试,默认配置
http://jeecg-boot-gateway:9999
- 如果你是部署服务器,需要将.env.production的VITE_GLOB_DOMAIN_URL修改成外网IP,如:http://199.45.125.150:9999
4. 编译前端项目
进入前端
cd JeecgBoot/jeecgboot-vue3
编译
pnpm i
pnpm run build
5. 修改前端Dockerfile
修改配置文件:jeecgboot-vue3/Dockerfile
- 把Host的 jeecg-boot-system 替换成 jeecg-boot-gateway
- 把proxy_pass的
http://jeecg-boot-system:8080/jeecg-boot
改成http://jeecg-boot-gateway:9999
location /jeecgboot/ {
# 必须有/
proxy_pass http://jeecg-boot-gateway:9999/;
proxy_redirect off;
proxy_set_header Host jeecg-boot-gateway;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
}
注意:location和proxy_pass最后以
/
结尾,否则gateway访问会出错
6. 启动镜像容器组
进入JeecgBoot根路径

执行docker命令
docker-compose -f docker-compose-cloud.yml up -d
Docker组启动成功

7. 访问系统
等待1分钟,待mysql数据初始化完成后,访问系统