version: '3.9'

#API + REDIS + InfluxDB
services:
  #API
  parr-api:
    image: harbor.dvgd.rzd/parr/parr-api:${tag:-latest}
    #container_name: parr-api
    #restart: always
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - TZ=Europe/Moscow
    ports:
      - 8082:80
    #volumes:
      #- /var/log/parr-api:/app/log
      #- parr_storage_dev:/app/Data
    logging:
      driver: fluentd
      options:
        fluentd-address: dvgd-efk-01.dvgd.oao.rzd:24224
        fluentd-retry-wait: '10s'
        fluentd-max-retries: '30'
        fluentd-async: 'true'
        fluentd-buffer-limit: '52428800'
        tag: parr.api.serilog
    networks:
      parr-network:
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:80/api/v1/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 120s
    deploy:
      replicas: 3
      update_config:
        parallelism: 1
        delay: 5s
        order: start-first
        failure_action: rollback
      rollback_config:
        parallelism: 1
        order: stop-first
      restart_policy:
        condition: any
        window: 120s

  # REDIS STACK
  parr-redis:
    image: redis/redis-stack:7.2.0-v6
    restart: always
    ports:
      - 6379:6379
    volumes:
      - parr_redis_data:/data
      #- parr_redis_config/redis.conf:/usr/local/etc/redis/redis.conf
    environment:
      - REDIS_ARGS=--requirepass ParrP@ssPtk202MMdevDvs
    deploy:
      replicas: 1
    networks:
      parr-network:

  # REDIS TO PROMETHEUS
  redis-exporter:
    image: oliver006/redis_exporter
    ports:
      - 9121:9121
    restart: unless-stopped
    environment:
      REDIS_ADDR: "parr-redis:6379"
      REDIS_USER: null
      REDIS_PASSWORD: ParrP@ssPtk202MMdevDvs
    deploy:
      replicas: 1
    networks:
      parr-network:

  # #REDIS
  # parr-redis:
  #   image: redis:7.2.3
  #   restart: always
  #   ports:
  #     - 6379:6379
  #   #command: redis-server /usr/local/etc/redis/redis.conf
  #   volumes:
  #     - parr_redis_data:/data
  #     #- parr_redis_config/redis.conf:/usr/local/etc/redis/redis.conf
  #   environment:
  #     - REDIS_PASSWORD=ParrP@ssPtk202MMdevDvs
  #     - REDIS_PORT=6379
  #     - REDIS_DATABASES=16
  #   deploy:
  #     replicas: 1
  #   networks:
  #     parr-network:

  # InfuxDB
  parr-influxdb:
    image: influxdb:2.7.6
    restart: always
    environment:
      - DOCKER_INFLUXDB_INIT_MODE=setup
      - DOCKER_INFLUXDB_INIT_USERNAME=parr-administrator
      - DOCKER_INFLUXDB_INIT_PASSWORD=P@ssParrAdminMT202!
      - DOCKER_INFLUXDB_INIT_ORG=parr
      - DOCKER_INFLUXDB_INIT_BUCKET=robots
      - DOCKER_INFLUXDB_INIT_RETENTION=30d
    ports:
      - 8086:8086
    volumes:
      - parr_influexdb_data:/var/lib/influxdb2
      - parr_influexdb_config:/etc/influxdb2
    deploy:
      replicas: 1
    networks:
      parr-network:


networks:
  parr-network:
    driver: overlay
    external: true

volumes:
  parr_redis_data:
    name: parr_redis_data
    driver_opts:
      type: "nfs"
      o: "addr=dvgd-appfs-01.dvgd.oao.rzd,soft,rw,nfsvers=4"
      device: ":/nfs/dvgd-swarm-01/parr_redis/data"
  # parr_redis_config:
  #   name: parr_redis_config
  #   driver_opts:
  #     type: "nfs"
  #     o: "addr=dvgd-appfs-01.dvgd.oao.rzd,soft,rw,nfsvers=4"
  #     device: ":/nfs/dvgd-swarm-01/parr_redis/config"
  #parr_storage_dev:
    #name: parr_storage_dev
    #driver: local
    #driver_opts:
      #type: cifs
      #o: "addr=dvgd-appfs-01,username=parruserdev,password=P@ssDevParr202MM"
      #device: //dvgd-appfs-01/parr_storage_dev
  parr_influexdb_data:
    name: parr_influexdb_data
    driver_opts:
      type: "nfs"
      o: "addr=dvgd-appfs-01.dvgd.oao.rzd,soft,rw,nfsvers=4"
      device: ":/nfs/dvgd-swarm-01/parr_influexdb/data"
  parr_influexdb_config:
    name: parr_influexdb_config
    driver_opts:
      type: "nfs"
      o: "addr=dvgd-appfs-01.dvgd.oao.rzd,soft,rw,nfsvers=4"
      device: ":/nfs/dvgd-swarm-01/parr_influexdb/config"




#tag=v1.0.0 docker compose up -d