version: '3.5'

services:
  hivemq_svc:
    restart: unless-stopped
    image: "docker.briq.it/public/hivemq-community-edition:master"
    env_file:
      - .env
    volumes:
      - ./hivemq.config.xml:/config.xml
    logging:
      driver: journald
      options:
        tag: hivemq-briq
    ports:
     - 127.0.0.1:1833:1833
     - 127.0.0.1:1834:1834
    networks:
      - bq_infrastructure_net
      - bq_infrastructure_ext_net

  postgres_svc:
    image: postgres:14
    restart: unless-stopped
    networks:
      - bq_infrastructure_net
      - bq_infrastructure_ext_net
    ports:
      - 127.0.0.1:5432:5432
    environment:
      POSTGRES_PASSWORD: LvdSkluLfE
      POSTGRES_USER: postgres
      POSTGRES_DB: postgres
    logging:
      driver: journald
      options:
        tag: postgres-briq
    #volumes:
    #  - ./data:/var/lib/postgresql/data
    #
    ## ATTENZIONE: avviare con volume qui sopra commentato, poi eseguire dalla cartella corrente (e poi decommentare il volume):
    ## docker-compose exec postgres_svc sh -c "tar -cpO -C /var/lib/postgresql data | base64" | base64 -di | tar -xp
  # nodered_svc:
  #   image: nodered/node-red:3.0.0
  #   restart: unless-stopped
  #   environment:
  #     - TZ=Europe/Rome
  #   ports:
  #     - "127.0.0.1:1880:1880"
  #     - "0.0.0.0:1890:1890" # per mandare il file da windows fuori (particolarità di eusebio)
  #   networks:
  #     - bq_infrastructure_net
  #     - bq_infrastructure_ext_net
  #   # volumes:
  #   #   - ./red_data:/data
  #   ## ATTENZIONE: avviare con volume qui sopra commentato, poi eseguire dalla cartella corrente (e poi decommentare il volume):
  #   ## mkdir -p red_data && docker-compose exec -u0 nodered_svc sh -c "tar -cpO -C /data . | base64" | base64 -di | sudo tar -C ./red_data -xp

  # # Questo è il relay. Usare come ultima spiaggia e soltanto con postgresql di sistema.
  # postgres_sys:
  #   image: docker.briq.it/public/psql_relay:master
  #   restart: unless-stopped
  #   networks:
  #     - postgres_sys_relay_net
  #   environment:
  #     - PSQL_SOCK_NAME=postgresql/.s.PGSQL.5432
  #   volumes: 
  #     - /var/run/:/psql_sock/

networks:
  postgres_sys_relay_net:
    name: postgres_sys_relay_net
    internal: true
  bq_infrastructure_net:
    name: bq_infrastructure_net
    internal: true
  bq_infrastructure_ext_net:
    name: bq_infrastructure_ext_net
  # # Usare in caso di bisogno di connettere servizi dell'host direttamente ai container
  # fixed_ip_host_net:
  #   name: fixed_ip_host_net
  #   ipam: 
  #     driver: default
  #     config:
  #       - subnet: 172.28.42.0/24