docker-compose.yml 4.0 KB
version: '3'

services:
  mysql:
    image: mysql:8.0.24
    container_name: mysql
    environment:
      # 时区上海
      TZ: Asia/Shanghai
      # root 密码
      MYSQL_ROOT_PASSWORD: root
      # 初始化数据库(后续的初始化sql会在这个库执行)
      MYSQL_DATABASE: ry-vue
    ports:
      - 3306:3306
    volumes:
      # 数据挂载
      - /docker/mysql/data/:/var/lib/mysql/
      # 配置挂载
      - /docker/mysql/conf/:/etc/mysql/conf.d/
      # 主机本机时间文件映射 与本机时间同步
      - /etc/localtime:/etc/localtime:ro
    command:
      # 将mysql8.0默认密码策略 修改为 原先 策略 (mysql8.0对其默认策略做了更改 会导致密码无法匹配)
      --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
    privileged: true
    restart: always
    networks:
      ruoyi_net:
        ipv4_address: 172.30.0.36

  nginx-web:
    # 如果需要指定版本 就把 latest 换成版本号
    image: nginx:latest
    container_name: nginx-web
    ports:
      - 80:80
      - 443:443
    volumes:
      # 证书映射
      - /docker/nginx/cert:/etc/nginx/cert
      # 配置文件映射
      - /docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
      # 页面目录
      - /docker/nginx/html:/usr/share/nginx/html
      # 日志目录
      - /docker/nginx/log:/var/log/nginx
      # 主机本机时间文件映射 与本机时间同步
      - /etc/localtime:/etc/localtime:ro
    privileged: true
    restart: always
    networks:
      - ruoyi_net

  redis:
    image: redis:6.2.1
    container_name: redis
    ports:
      - 6379:6379
    environment:
      # 设置环境变量 时区上海 编码UTF-8
      TZ: Asia/Shanghai
      LANG: en_US.UTF-8
    volumes:
      # 配置文件
      - /docker/redis/conf/redis.conf:/redis.conf:rw
      # 数据文件
      - /docker/redis/data:/data:rw
      # 主机本机时间文件映射 与本机时间同步
      - /etc/localtime:/etc/localtime:ro
    command: "redis-server --appendonly yes"
    privileged: true
    restart: always
    networks:
      ruoyi_net:
        ipv4_address: 172.30.0.48

  minio:
    image: minio/minio:RELEASE.2021-07-08T01-15-01Z
    hostname: "minio"
    ports:
      # api 端口
      - 9000:9000
      # 控制台端口
      - 9001:9001
    environment:
      # 管理后台用户名
      MINIO_ACCESS_KEY: ruoyi
      # 管理后台密码,最小8个字符
      MINIO_SECRET_KEY: ruoyi123
    volumes:
      # 映射当前目录下的data目录至容器内/data目录
      - /docker/minio/data:/data
      # 映射配置目录
      - /docker/minio/config:/root/.minio/
      # 主机本机时间文件映射 与本机时间同步
      - /etc/localtime:/etc/localtime:ro
    command: server --console-address ':9001' /data  # 指定容器中的目录 /data
    privileged: true
    restart: always
    networks:
      ruoyi_net:
        ipv4_address: 172.30.0.54

  ruoyi-server1:
    image: "ruoyi/ruoyi-server:2.6.0"
    environment:
      - TZ=Asia/Shanghai
    volumes:
      # 配置文件
      - /docker/server1/logs/:/ruoyi/server/logs/
      - /docker/ruoyi/uploadPath/:/ruoyi/server/ruoyi/uploadPath/
    privileged: true
    restart: always
    networks:
      ruoyi_net:
        ipv4_address: 172.30.0.60

  ruoyi-server2:
    image: "ruoyi/ruoyi-server:2.6.0"
    environment:
      - TZ=Asia/Shanghai
    volumes:
      # 配置文件
      - /docker/server2/logs/:/ruoyi/server/logs/
      - /docker/ruoyi/uploadPath/:/ruoyi/server/ruoyi/uploadPath/
    privileged: true
    restart: always
    networks:
      ruoyi_net:
        ipv4_address: 172.30.0.61

  ruoyi-monitor-admin:
    image: "ruoyi/ruoyi-monitor-admin:2.6.0"
    environment:
      - TZ=Asia/Shanghai
    privileged: true
    restart: always
    networks:
      ruoyi_net:
        ipv4_address: 172.30.0.90

networks:
  ruoyi_net:
    driver: bridge
    ipam:
      config:
        - subnet: 172.30.0.0/16