version: '2.4'

services:
  postgres: # 数据库连接：jdbc:postgresql://{ip}:5432/{dbname} 用户名：postgres 密码：heliang
    image: postgres:12.10
    restart: always
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: heliang
      POSTGRES_DB: postgres
      PGDATA: /var/lib/postgresql/data/pgdata
      LANG: C.UTF-8
      TZ: Asia/Shanghai
    volumes:
      - ./postgres/data/:/var/lib/postgresql/data/pgdata/:rw
      - ./postgres/init.d/:/docker-entrypoint-initdb.d/:rw
      - ./postgres/sql/:/sql/:rw
      - ./postgres/upgrade/:/upgrade/:rw
    networks:
      - mobe-network
    privileged: true
  xxl-job: #分布式任务调度 http://{ip}:8866/xxl-job-admin 后台登录用户名：admin 密码：123456
    image: heliang230/xxl-job-admin:2.3.0
    restart: always
    environment:
      APPLICATION_PORT: 8866 #调度中心web界面访问端口
      SERVER_SERVLET_CONTEXTPATH: /xxl-job-admin #web上下文
      POSTGRES_SERVICE_HOST: postgres #数据库
      POSTGRES_SERVICE_PORT: 5432 #数据库端口
      POSTGRES_SERVICE_DB_NAME: xxl_job #数据库名称
      POSTGRES_SERVICE_USER: postgres #数据库用户名
      POSTGRES_SERVICE_PASSWORD: heliang #数据库密码
      SERVICE_ACCESSTOKEN: d1bacd94024ed228 #调度中心与执行器服务认证凭证
      JAVA_OPTS: -Xmx512m
    volumes:
      - ./xxl-job/data/:/data/:rw
    ports:
      - 8866:8866
    networks:
      - mobe-network
    privileged: true
    depends_on:
      - postgres
  xxl-job-executor: #执行器
    image: heliang230/xxl-job-executor:2.3.2
    restart: always
    environment:
      SERVER_PORT: 8080 #执行器API端口
      SPRING_MAIN_WEB_ENVIRONMENT: "true" #是否开启web模式
      XXL_JOB_ADMIN_ADDRESSES: http://xxl-job:8866/xxl-job-admin #调度中心地址
      XXL_JOB_ACCESSTOKEN: d1bacd94024ed228 #执行器与调度中心token凭证
      XXL_JOB_EXECUTOR_APPNAME: xxl-job-executor #执行器应用名称
      XXL_JOB_EXECUTOR_ADDRESS: http://xxl-job-executor:9999/ #注册到调度中心的执行器地址信息
      XXL_JOB_EXECUTOR_IP: xxl-job-executor #执行器ip地址
      XXL_JOB_EXECUTOR_PORT: 9999 #执行器端口
      XXL_JOB_EXECUTOR_LOGPATH: /data/applogs/xxl-job/jobhandler #日志存储路径
      XXL_JOB_EXECUTOR_LOGRETENTIONDAYS: 30 #存储日志时间
      JAVA_OPTS: -Xmx512m
      SLEEP: 5 #启动容器后，休眠5秒中,为了防止报错
    volumes:
      - ./xxl-job-executor/data/:/data/:rw
    ports:
      - 8080:8080
    networks:
      - mobe-network
    privileged: true
    depends_on:
      - postgres
      - xxl-job
networks:
  mobe-network:


