后端服务部署
SmartCall 后端基于 Spring Boot 构建,提供 REST API 和 WebSocket 服务。
在部署 SmartCall 后端服务之前,请确保您已经完成了后端服务配置
SmartCall 后端服务部署分为单体服务部署和微服务部署两种模式,根据您的需求选择相应的部署方式。
1. 单体服务部署
- 先在项目根目录下执行以下命令进行服务构建
mvn clean package -DskipTests
- 以上命令执行完毕后,会在
smart-boot/target目录下生成可执行的 JAR 文件
- 在项目
smart-boot目录下执行以下命令进行镜像构建
docker build -t smartaster:1.0.0 .
- 在服务器上创建文件
/app/smartaster/docker-compose.yml,并复制以下内容到文件内
services:
smartaster:
image: "smartaster:1.0.0"
hostname: "smartaster"
container_name: "smartaster"
extra_hosts:
- "host.docker.internal:host-gateway"
privileged: true
ports:
- "9999:9999"
restart: always
- 在目录
/app/smartaster下,执行以下命令启动服务
docker-compose up -d
- 执行以下命令可以查看服务是否启动成功
docker-compose ps
2. 微服务部署
- 在项目根目录下执行以下命令
mvn clean package -DskipTests
mvn dockerfile:build
- 在服务器上创建文件
/app/smartaster/docker-compose.yml,并复制以下内容到文件内
services:
smart-log:
image: "127.0.0.1/smart/smart-log:1.0.0"
hostname: "smart-log"
container_name: "smart-log"
privileged: true
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "17000:17000"
restart: always
smart-resource:
image: "127.0.0.1/smart/smart-resource:1.0.0"
hostname: "smart-resource"
container_name: "smart-resource"
privileged: true
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "9004:9004"
restart: always
smart-system:
image: "127.0.0.1/smart/smart-system:1.0.0"
hostname: "smart-system"
container_name: "smart-system"
privileged: true
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "9002:9002"
restart: always
smart-user:
image: "127.0.0.1/smart/smart-user:1.0.0"
hostname: "smart-user"
container_name: "smart-user"
privileged: true
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "9003:9003"
restart: always
smart-gateway:
image: "127.0.0.1/smart/smart-gateway:1.0.0"
hostname: "smart-gateway"
container_name: "smart-gateway"
privileged: true
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "9000:9000"
restart: always
smart-auth:
image: "127.0.0.1/smart/smart-auth:1.0.0"
hostname: "smart-auth"
container_name: "smart-auth"
privileged: true
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "9001:9001"
restart: always
smart-maxkb:
image: "127.0.0.1/smart/smart-maxkb:1.0.0"
hostname: "smart-maxkb"
container_name: "smart-maxkb"
privileged: true
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "9011:9011"
restart: always
smart-aster:
image: "127.0.0.1/smart/smart-aster:1.0.0"
hostname: "smart-aster"
container_name: "smart-aster"
privileged: true
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "9010:9010"
restart: always
- 如果需要接口文档,在
/app/smartaster/docker-compose.yml中添加以下内容
smart-doc:
image: "127.0.0.1/smart/smart-doc:1.0.0"
hostname: "smart-doc"
container_name: "smart-doc"
privileged: true
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "18000:18000"
restart: always
- 如果需要admin监控,在
/app/smartaster/docker-compose.yml中添加以下内容
smart-admin:
image: "127.0.0.1/smart/smart-admin:1.0.0"
hostname: "smart-admin"
container_name: "smart-admin"
privileged: true
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "8868:8868"
restart: always
- 在目录
/app/smartaster下,执行以下命令启动服务
docker-compose up -d
- 执行以下命令可以查看服务是否启动成功
docker-compose ps
💡 提示: 更细节的部署方式可以参考JPower文档
💡 提示: 本项目支持接入你自己的微服务体系,只需要按照微服务模式部署
smart-aster和smart-maxkb模块即可,和你其他服务都接入一个nacos即可。
