# 构建 PowerJob 测试环境

version: '3.7'
services:
  powerjob-mysql:
    build:
      context: ../
    environment:
      MYSQL_ROOT_HOST: "%"
      MYSQL_ROOT_PASSWORD: No1Bug2Please3!
    deploy:
      resources:
        limits:
          memory: 640M
    restart: always
    container_name: powerjob-mysql
    image: powerjob/powerjob-mysql:test_env
    ports:
      - "3309:3306"
    volumes:
      - ~/powerjob-data/powerjob-mysql:/var/lib/mysql
    command: --lower_case_table_names=1
  powerjob-mongodb:
    image: mongo:latest
    container_name: powerjob-mongodb
    restart: always
    deploy:
      resources:
        limits:
          memory: 256M
    environment:
      MONGO_INITDB_ROOT_USERNAME: "root"
      MONGO_INITDB_ROOT_PASSWORD: "No1Bug2Please3!"
      MONGO_INITDB_DATABASE: "powerjob_daily"
    ports:
      - "27017:27017"
    volumes:
      - ./testenv/init_mongodb.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
      - ~/powerjob-data/powerjob-mongodb:/data/db
  powerjob-server:
    build:
      context: ../../powerjob-server/docker
    deploy:
      resources:
        limits:
          memory: 768M
    container_name: powerjob-server
    image: powerjob/powerjob-server:test_env
    restart: always
    depends_on:
      - powerjob-mysql
      - powerjob-mongodb
    environment:
      PARAMS: "--spring.profiles.active=product --oms.mongodb.enable=true --spring.data.mongodb.uri=mongodb://zqq:No1Bug2Please3!@powerjob-mongodb/powerjob_daily?retryWrites=true&w=majority --spring.datasource.core.jdbc-url=jdbc:mysql://powerjob-mysql:3306/powerjob-daily?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai"
      JVMOPTIONS: "-server -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=7 -XX:GCLogFileSize=100M -Xloggc:/root/powerjob/server/gc.log"
    ports:
      - "7700:7700"
      - "10086:10086"
      - "10010:10010"
    volumes:
      - ~/powerjob-data/powerjob-server:/root/powerjob/server/
      - ~/.m2:/root/.m2

  powerjob-worker-agent:
    build:
      context: ../../powerjob-worker-agent
    deploy:
      resources:
        limits:
          memory: 384M
    container_name: powerjob-worker-agent
    image: powerjob/powerjob-worker-agent:test_env
    restart: always
    depends_on:
      - powerjob-mysql
      - powerjob-server
    ports:
      - "5002:5005"
      - "10002:10000"
      - "27777:27777"
    volumes:
      - ~/powerjob-data/powerjob-worker-agent:/root
    entrypoint:
      - "sh"
      - "-c"
      - "./wait-for-it.sh powerjob-server:7700 --strict -- java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10000 -Dcom.sun.management.jmxremote.rmi.port=10000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -server -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=7 -XX:GCLogFileSize=100M -Xloggc:/root/gc.log -jar /powerjob-agent.jar --app powerjob-worker-samples --server powerjob-server:7700"

  powerjob-worker-agent2:
    deploy:
      resources:
        limits:
          memory: 384M
    container_name: powerjob-worker-agent2
    image: powerjob/powerjob-worker-agent:test_env
    restart: always
    depends_on:
      - powerjob-mysql
      - powerjob-server
    ports:
      - "5003:5005"
      - "10003:10000"
      - "27778:27777"
    volumes:
      - ~/powerjob-data/powerjob-worker-agent2:/root
    entrypoint:
      - "sh"
      - "-c"
      - "./wait-for-it.sh powerjob-server:7700 --strict -- java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10000 -Dcom.sun.management.jmxremote.rmi.port=10000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -server -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=7 -XX:GCLogFileSize=100M -Xloggc:/root/gc.log -jar /powerjob-agent.jar --app powerjob-worker-samples --server powerjob-server:7700"

