商业版 · 部署文档
商业版/部署文档/后端服务部署

后端服务部署

SmartAster 后端基于 Spring Boot 构建,提供 REST API 和 WebSocket 服务。

在部署 SmartAster 后端服务之前,请确保您已经完成了后端服务配置

SmartAster 后端服务部署分为单体服务部署和微服务部署两种模式,根据您的需求选择相应的部署方式。

💡 提示: jib:build是上传镜像到远程仓库,需要修改根pom.xml中远程仓库地址,如果是构建镜像到本机docker需要把jib:build命令替换成jib:dockerBuild,如果是构建出镜像文件用于上传到服务器则把jib:build命令替换成jib:buildTar

1. 单体服务部署

  1. 先在项目根目录下执行以下命令进行服务构建
mvn clean compile jib:build  -DskipTests
  1. 在服务器上创建文件/app/smartaster/docker-compose.yml,并复制以下内容到文件内
services:
  smartaster:
    image: "smart/smart-boot:1.0.1"
    hostname: "smartaster"
    container_name: "smartaster"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    privileged: true
    ports:
      - "9999:9999"
    restart: always
  1. 在目录/app/smartaster下,执行以下命令启动服务
docker-compose up -d
  1. 执行以下命令可以查看服务是否启动成功
docker-compose ps

2. 微服务部署

  1. 在项目根目录下执行以下命令
mvn clean compile jib:build  -DskipTests
  1. 在服务器上创建文件/app/smartaster/docker-compose.yml,并复制以下内容到文件内
services:
  smart-log:
    image: "smart/smart-log:1.0.1"
    hostname: "smart-log"
    container_name: "smart-log"
    privileged: true
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "17000:17000"
    restart: always
  
  smart-resource:
    image: "smart/smart-resource:1.0.1"
    hostname: "smart-resource"
    container_name: "smart-resource"
    privileged: true
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "9004:9004"
    restart: always
  
  smart-system:
    image: "smart/smart-system:1.0.1"
    hostname: "smart-system"
    container_name: "smart-system"
    privileged: true
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "9002:9002"
    restart: always
  
  smart-user:
    image: "smart/smart-user:1.0.1"
    hostname: "smart-user"
    container_name: "smart-user"
    privileged: true
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "9003:9003"
    restart: always

  smart-gateway:
    image: "smart/smart-gateway:1.0.1"
    hostname: "smart-gateway"
    container_name: "smart-gateway"
    privileged: true
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "9000:9000"
    restart: always
  
  smart-auth:
    image: "smart/smart-auth:1.0.1"
    hostname: "smart-auth"
    container_name: "smart-auth"
    privileged: true
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "9001:9001"
    restart: always
  
  smart-maxkb:
    image: "smart/smart-maxkb:1.0.1"
    hostname: "smart-maxkb"
    container_name: "smart-maxkb"
    privileged: true
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "9011:9011"
    restart: always
    
  smart-aster:
    image: "smart/smart-aster:1.0.1"
    hostname: "smart-aster"
    container_name: "smart-aster"
    privileged: true
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "9010:9010"
    restart: always
  1. 如果需要接口文档,在/app/smartaster/docker-compose.yml中添加以下内容
  smart-doc:
    image: "smart/smart-doc:1.0.1"
    hostname: "smart-doc"
    container_name: "smart-doc"
    privileged: true
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "18000:18000"
    restart: always
  1. 如果需要admin监控,在/app/smartaster/docker-compose.yml中添加以下内容
  smart-admin:
    image: "smart/smart-admin:1.0.1"
    hostname: "smart-admin"
    container_name: "smart-admin"
    privileged: true
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "8868:8868"
    restart: always
  1. 在目录/app/smartaster下,执行以下命令启动服务
docker-compose up -d
  1. 执行以下命令可以查看服务是否启动成功
docker-compose ps

💡 提示: 更细节的部署方式可以参考JPower文档

💡 提示: 本项目支持接入你自己的微服务体系,只需要按照微服务模式部署smart-aster和smart-maxkb模块即可,和你其他服务都接入一个nacos即可。