快速部署

获取源代码后可通过以下两种方式部署程序。

docker方式

  1. 安装docker

  2. 使用maven命令将项目打包
    在代码根目录执行:

  1. mvn clean package -Dmaven.test.skip=true

3.使用docker构建镜像

注意

请自行准备docker镜像仓库,此处以registry.cn-shenzhen.aliyuncs.com阿里云私有仓库为例。

  1. cd ./jetlinks-standalone
  2. docker build -t registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-standalone
  3. docker push registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-standalone

4.拉取镜像
在需要部署的服务器上拉取构建成功的镜像。

  1. docker pull registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-standalone

5.创建docker-compose文件

  1. version: '2'
  2. services:
  3. redis:
  4. image: redis:5.0.4
  5. container_name: jetlinks-redis
  6. ports:
  7. - "6379:6379"
  8. volumes:
  9. - "./data/redis:/data"
  10. command: redis-server --appendonly yes
  11. environment:
  12. - TZ=Asia/Shanghai
  13. elasticsearch:
  14. image: elasticsearch:6.7.2
  15. container_name: jetlinks-elasticsearch
  16. environment:
  17. ES_JAVA_OPTS: -Djava.net.preferIPv4Stack=true -Xms1g -Xmx1g
  18. transport.host: 0.0.0.0
  19. discovery.type: single-node
  20. bootstrap.memory_lock: "true"
  21. discovery.zen.minimum_master_nodes: 1
  22. discovery.zen.ping.unicast.hosts: elasticsearch
  23. volumes:
  24. - elasticsearch-volume:/usr/share/elasticsearch/data
  25. ports:
  26. - "9200:9200"
  27. - "9300:9300"
  28. kibana:
  29. image: kibana:6.7.2
  30. container_name: jetlinks-kibana
  31. environment:
  32. ELASTICSEARCH_URL: http://elasticsearch:9200
  33. links:
  34. - elasticsearch:elasticsearch
  35. ports:
  36. - "5601:5601"
  37. depends_on:
  38. - elasticsearch
  39. postgres:
  40. image: postgres:11-alpine
  41. container_name: jetlinks-postgres
  42. ports:
  43. - "5432:5432"
  44. volumes:
  45. - "./data/postgres:/var/lib/postgresql/data"
  46. environment:
  47. POSTGRES_PASSWORD: jetlinks
  48. POSTGRES_DB: jetlinks
  49. TZ: Asia/Shanghai
  50. rabbitmq:
  51. image: rabbitmq:management-alpine
  52. container_name: rabbitmq
  53. environment:
  54. - RABBITMQ_DEFAULT_USER=admin
  55. - RABBITMQ_DEFAULT_PASS=jetlinks
  56. - RABBITMQ_ERLANG_COOKIE=jetlinks
  57. ports:
  58. - "15672:15672"
  59. - "5672:5672"
  60. jetlinks:
  61. image: registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-standalone:1.2-SNAPSHOT #版本号同源代码pom.xml中的版本号同步
  62. container_name: jetlinks-ce
  63. ports:
  64. - 8848:8848 # API端口
  65. - 1883:1883 # MQTT端口
  66. - 8000:8000 # 预留
  67. - 8001:8001 # 预留
  68. - 8002:8002 # 预留
  69. volumes:
  70. - "jetlinks-volume:/static/upload" # 持久化上传的文件
  71. environment:
  72. # - "JAVA_OPTS=-Xms4g -Xmx18g -XX:+UseG1GC"
  73. - "hsweb.file.upload.static-location=http://127.0.0.1:8848/upload" #上传的静态文件访问根地址,为ui的地址.
  74. - "spring.r2dbc.url=r2dbc:postgresql://postgres:5432/jetlinks" #数据库连接地址
  75. - "spring.r2dbc.username=postgres"
  76. - "spring.r2dbc.password=jetlinks"
  77. - "elasticsearch.client.host=elasticsearch"
  78. - "elasticsearch.client.post=9200"
  79. - "spring.redis.host=redis"
  80. - "spring.redis.port=6379"
  81. - "logging.level.io.r2dbc=warn"
  82. - "logging.level.org.springframework.data=warn"
  83. - "logging.level.org.springframework=warn"
  84. - "logging.level.org.jetlinks=warn"
  85. - "logging.level.org.hswebframework=warn"
  86. - "logging.level.org.springframework.data.r2dbc.connectionfactory=warn"
  87. links:
  88. - redis:redis
  89. - postgres:postgres
  90. - elasticsearch:elasticsearch
  91. depends_on:
  92. - postgres
  93. - redis
  94. - elasticsearch
  95. volumes:
  96. postgres-volume:
  97. redis-volume:
  98. elasticsearch-volume:
  99. jetlinks-volume:

注意:

jetlinks docker镜像版本更新和源代码根目录下文件pom.xml中的版本号同步

6.运行docker-compose文件

  1. docker-compose up -d

jar包方式

1.使用maven命令将项目打包
在代码根目录执行:

  1. mvn clean package -Dmaven.test.skip=true

2.将jar包上传到需要部署的服务器上。

3.使用java命令运行jar包

  1. java -jar jetlinks-standalone.jar

前端部署

1.获取源代码

  1. git clone https://github.com/jetlinks/jetlinks-ui-antd.git

2.使用npm打包,并将打包后的文件复制到项目的docker目录下(命令在项目根目录下执行)

  1. npm install
  2. npm run-script build
  3. cp -r dist docker/

3.构建docker镜像

  1. docker build -t docker build -t registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-ui-antd:1.0-SNAPSHOT ./docker

4.运行docker镜像

  1. docker run -it --rm -p 9000:80 -e "API_BASE_PATH=http://xxx:8848/" registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-ui-antd:1.0-SNAPSHOT

注意

环境变量API_BASE_PATH为后台API根地址. 由docker容器内进行自动代理. 请根据自己的系统环境配置环境变量: API_BASE_PATH

前端环境要求

  • nodeJs v12.14
  • npm v6.13