version: "3"
services:
  adminer:
    networks:
      - pts-network
      - rabbitmq_go_net
    image: adminer:latest
    container_name: pts_myadmin
    environment:
      ADMINER_DEFAULT_SERVER: mysql
      DB_SERVER: pts_mysql
      DB_USER: root
      DB_PASS: password
    depends_on:
      - mysql
    ports:
      - "8081:8080"
    restart: always
  #
#  grafana:
#    networks:
#      - pts-network
#      - rabbitmq_go_net
#    image: grafana/grafana-enterprise
#    container_name: pts_grafana
#    #environment:
#    depends_on:
#      - mysql
#    volumes:
#      - grafana-volume:/var/lib/grafana
#    ports:
#      - "3000:3000"
#    restart: always
  #
  app:
    networks:
      - pts-network
      - rabbitmq_go_net
    environment:
      - DEBUG=YES
      - TZ=America/Detroit
      - _JAVA_OPTIONS=-Xms1024m -Xmx8192m
    image: davidabbey/pickthestick:latest
    volumes:
    - docker_pts_mysql_data:/var/lib/mysql
    - shared-volume:/var/lib/java
    container_name: pts_container
    hostname: pts_container
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    ports:
      - "8484:8484"
      - "80:8080"
      - "9091:9091"
      - "8443:8443"
    healthcheck:
      test: curl -h localhost:8080
      interval: 5s
      timeout: 5s
      retries: 55
    restart: always
    build:
      context: ./app/
      dockerfile: Dockerfile
      args:
        USER: pts
        GROUP: pts
        uid: 1010
        gid: 1010
        http_port: 8080
        TINI_VERSION: 0.14.0
        TINI_SHA: 6c41ec7d33e857d4779f14d9c74924cab0c7973485d2972419a3b7c7620ff5fd
        CORRETTO_VERSION: "21"
    privileged: true
    deploy:
      resources:
        limits:
          cpus: "2"
          memory: "4g"
    depends_on:
      - mysql
##
  mysql:
    #image: mysql:8.0.37-debian
    image: davidabbey/mysql
    container_name: pts_mysql
    hostname: pts_mysql
    networks:
      - pts-network
      - rabbitmq_go_net
    environment:
      MYSQL_ROOT_PASSWORD: password
      TZ: America/Detroit
      mysql-native-password: "ON"
    ports:
      - "33061:3306"
    restart: always
    volumes:
      - docker_pts_mysql_data:/var/lib/mysql
      - shared-volume:/var/lib/java
    build:
      context: ./mysql
      dockerfile: Dockerfile
    privileged: true
#
  rabbitMQ:
    networks:
      - rabbitmq_go_net
      - pts-network
    environment:
      - DEBUG=NO
      - TZ=America/Detroit
      #- ERL_MAX_PORTS=500000
      #- RABBITMQ_VM_MEMORY_HIGH_WATERMARK=1536MB
    ports:
      - "5672:5672"
      - "15672:15672"
    depends_on:
      - mysql
    deploy:
      resources:
        limits:
          cpus: "2"
          memory: "2g"
        reservations:
          memory: "1g"
    image: rabbitmq:management
    privileged: true
    volumes:
      - shared-volume:/var/lib/java
      #- ./MQserver/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
    healthcheck:
      test: rabbitmq-diagnostics -q ping
      interval: 30s
      timeout: 10s
      retries: 5
    hostname: rabbitmq
    container_name: rabbitmq
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    restart: always
    build:
      context: ./MQserver
      dockerfile: Dockerfile

#
#  sender:
#    networks:
#      - rabbitmq_go_net
#      - pts-network
#    environment:
#      - DEBUG=NO
#      - TZ=America/Detroit
#      - _JAVA_OPTIONS=-Xms1024m -Xmx8192m
#    image: davidabbey/sender:latest
#    container_name: sender
#    hostname: sender
#    stdin_open: true # docker run -i
#    tty: true        # docker run -t
#    restart: always
#    build:
#      context: ./sender
#      Dockerfile: Dockerfile$
#      args:
#        CORRETTO_VERSION: "21"
#    privileged: true
  #
  receiver:
    networks:
      - rabbitmq_go_net
      - pts-network
    environment:
      - DEBUG=NO
      - TZ=America/Detroit
      - _JAVA_OPTIONS=-Xms1024m -Xmx8192m
    image: davidabbey/receiver:latest
    volumes:
      - shared-volume:/var/lib/java
    container_name: receiver
    hostname: receiver
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    restart: always
    #depends_on:
    #  app:
    #    condition: service_healthy
    build:
      context: ./receiver
      dockerfile: Dockerfile
      args:
        CORRETTO_VERSION: "21"
    privileged: true
#
  mlbservice:
    networks:
      - rabbitmq_go_net
      - pts-network
    environment:
      - DEBUG=NO
      - TZ=America/Detroit
      - _JAVA_OPTIONS=-Xms1024m -Xmx8192m
    image: davidabbey/mlb:latest
    volumes:
      - shared-volume:/var/lib/java
    container_name: mlbservice
    hostname: mlbservicepts_mysql
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    restart: always
    build:
      context: ./mlb
      dockerfile: Dockerfile
      args:
        CORRETTO_VERSION: "21"
    privileged: true
#
volumes:
  docker_pts_mysql_data:
  pts_mysql_data:
  shared-volume:
  grafana-volume: {}
networks:
  { pts-network:, rabbitmq_go_net: }
