JPAAS采用Docker在线部署
前提
需要安装docker, docker-compose,推荐服务器系统为Centos7.6 64位以上.
部署步骤
1.基础软件结构
系统环境变量,可以配置不同镜像采用不通的版本,镜像仓库可以自己搭建,本地将代码编译镜像并推送到镜像服务器。
基础软件镜像目录
2.上传前端代码编译文件
示例如下:
3.创建docker-compose.yml文件
示例如下:
version: '3'
services:
mysql:
restart: always
image: mysql:8
container_name: mysql8
ports:
- 3306:3306
command:
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--default-time-zone=+8:00
environment:
MYSQL_ROOT_PASSWORD: "root"
volumes:
- ./mysql/db:/var/lib/mysql
- ./mysql/conf/my.cnf:/etc/my.cnf
- ./mysql/init:/docker-entrypoint-initdb.d/
- ./mysql/sql:/opt/sql
networks:
jpaas_net:
ipv4_address: 172.30.0.3
redis:
image: redis:5.0.8-alpine
hostname: "jpaas-redis"
environment:
- TZ=Asia/Shanghai
ports:
- 3379:6379
volumes:
- ./redis/data:/data
command: "redis-server --appendonly yes"
privileged: true
restart: always
tty: true # 这里可以加
networks:
jpaas_net:
ipv4_address: 172.30.0.4
nacos:
image: nacos/nacos-server:1.3.2 # 镜像`nacos/nacos-server:latest`
container_name: nacos_server # 容器名为'nacos_server'
restart: always # 指定容器退出后的重启策略为始终重启
volumes: # 数据卷挂载路径设置,将本机目录映射到容器目录
- ./nacos/logs/:/home/nacos/logs
- ./nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties
environment:
# 设置环境变量,相当于docker run命令中的-e
PREFER_HOST_MODE: hostname
MODE: standalone # 单机模式启动
SPRING_DATASOURCE_PLATFORM: mysql
MYSQL_SERVICE_HOST: 172.30.0.3 #172.18.0.2 # 注:这里不能为`127.0.0.1`或`localhost`方式!!!
MYSQL_SERVICE_DB_NAME: nacos_config # 所需sql脚本位于 `nacos-mysql/nacos-mysql.sql`
MYSQL_SERVICE_PORT: 3306
MYSQL_SERVICE_USER: root
MYSQL_SERVICE_PASSWORD: root
JVM_XMS: 512m
JVM_MMS: 320m
ports: # 映射端口
- 8848:8848
depends_on:
- mysql
networks:
jpaas_net:
ipv4_address: 172.30.0.48
seata:
image: seataio/seata-server
hostname: "seata-server"
ports:
- 8091:8091
depends_on:
- nacos
environment:
- SEATA_CONFIG_NAME=file:/root/seata-config/registry
- SEATA_PORT=8091
- STORE_MODE=file
#- SEATA_IP=192.168.0.200
- TZ=Asia/Shanghai
volumes:
- ./seata/conf:/root/seata-config
- ./seata/logs:/root/logs
- /etc/localtime:/etc/localtime
networks:
jpaas_net:
ipv4_address: 172.30.0.68
nginx:
image: nginx:stable-alpine-perl
hostname: "web-nginx"
environment:
- TZ=Asia/Shanghai
ports:
- 8080:8080
volumes:
- ./nginx/web/html:/usr/share/nginx/html
- ./nginx/web/nginx.conf:/etc/nginx/nginx.conf
privileged: true
restart: always
networks:
- jpaas_net
gateway:
image: "${REGISTER}/sc-gateway:${BASE_TAG}"
environment:
- TZ=Asia/Shanghai
privileged: true
restart: always
depends_on:
- seata
- mysql
- nacos
- redis
networks:
jpaas_net:
ipv4_address: 172.30.0.81
auth:
image: "${REGISTER}/jpaas-auth:${BASE_TAG}"
environment:
- TZ=Asia/Shanghai
privileged: true
restart: always
depends_on:
- mysql
- nacos
- redis
- seata
networks:
jpaas_net:
ipv4_address: 172.30.0.91
user:
image: "${REGISTER}/jpaas-user:${BUSINESS_TAG}"
environment:
- TZ=Asia/Shanghai
privileged: true
restart: always
depends_on:
- mysql
- nacos
- redis
- seata
networks:
- jpaas_net
system:
image: "${REGISTER}/jpaas-system:${BUSINESS_TAG}"
environment:
- TZ=Asia/Shanghai
privileged: true
restart: always
depends_on:
- mysql
- nacos
- redis
- seata
networks:
- jpaas_net
bpm:
image: "${REGISTER}/jpaas-bpm:${BASE_TAG}"
environment:
- TZ=Asia/Shanghai
privileged: true
restart: always
depends_on:
- mysql
- nacos
- redis
- seata
networks:
- jpaas_net
form:
image: "${REGISTER}/jpaas-form:${BASE_TAG}"
environment:
- TZ=Asia/Shanghai
privileged: true
restart: always
depends_on:
- mysql
- nacos
- redis
- seata
networks:
- jpaas_net
portal:
image: "${REGISTER}/jpaas-portal:${BUSINESS_TAG}"
environment:
- TZ=Asia/Shanghai
privileged: true
restart: always
depends_on:
- mysql
- nacos
- redis
- seata
networks:
- jpaas_net
job:
image: "${REGISTER}/job-admin:${BUSINESS_TAG}"
environment:
- TZ=Asia/Shanghai
privileged: true
restart: always
ports:
- 7878:7878
depends_on:
- mysql
- nacos
- redis
networks:
jpaas_net
ipv4_address: 172.30.0.78
networks:
jpaas_net:
driver: bridge
ipam:
config:
- subnet: 172.30.0.0/16
4.运行基础软件容器
docker-compose up -d mysql redis nacos seata-server nginx
5.运行JPAAS容器
docker-compose up -d
文档更新时间: 2022-01-11 23:18 作者:zyg