name: "road_vision"
services:
  mqtt:
    image: eclipse-mosquitto
    container_name: mqtt
    volumes:
      - ./agent/docker/mosquitto:/mosquitto
      - ./agent/docker/mosquitto/data:/mosquitto/data
      - ./agent/docker/mosquitto/log:/mosquitto/log
    ports:
      - 1883:1883
      - 9001:9001
    networks:
      mqtt_network:


  fake_agent:
    container_name: agent
    build:
      context: .
      dockerfile: agent/Dockerfile
    depends_on:
      - mqtt
    environment:
      MQTT_BROKER_HOST: "mqtt"
      MQTT_BROKER_PORT: 1883
      MQTT_TOPIC: "agent_data_topic"
      DELAY: 0.1
    networks:
      mqtt_network:

  edge:
    container_name: edge
    build:
      context: .
      dockerfile: edge/Dockerfile
    depends_on:
      - mqtt
    environment:
      MQTT_BROKER_HOST: "mqtt"
      MQTT_BROKER_PORT: 1883
      MQTT_TOPIC: " "
      HUB_HOST: "store"
      HUB_PORT: 8000
      HUB_MQTT_BROKER_HOST: "mqtt"
      HUB_MQTT_BROKER_PORT: 1883
      HUB_MQTT_TOPIC: "processed_data_topic"
    networks:
      mqtt_network:
      edge_hub:

  postgres_db:
    image: postgres:17
    container_name: postgres_db
    restart: always
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: pass
      POSTGRES_DB: test_db
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./store/docker/db/structure.sql:/docker-entrypoint-initdb.d/structure.sql
    ports:
      - "5432:5432"
    networks:
      db_network:

  pgadmin:
    container_name: pgadmin4
    image: dpage/pgadmin4
    restart: always
    environment:
      PGADMIN_DEFAULT_EMAIL: admin@admin.com
      PGADMIN_DEFAULT_PASSWORD: root
    volumes:
      - pgadmin-data:/var/lib/pgadmin
    ports:
      - "5050:80"
    networks:
      db_network:


  store:
    container_name: store
    build:
      context: .
      dockerfile: store/Dockerfile
    depends_on:
      - postgres_db
    restart: always
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: pass
      POSTGRES_DB: test_db
      POSTGRES_HOST: postgres_db
      POSTGRES_PORT: 5432
    ports:
      - "8000:8000"
    networks:
      db_network:
      hub_store:


  redis:
    image: redis:latest
    container_name: redis
    ports:
      - "6379:6379"
    networks:
      hub_redis:


  hub:
    container_name: hub
    build:
      context: .
      dockerfile: hub/Dockerfile
    depends_on:
      - mqtt
      - redis
      - store
    environment:
      STORE_API_HOST: "store"
      STORE_API_PORT: 8000
      REDIS_HOST: "redis"
      REDIS_PORT: 6379
      MQTT_BROKER_HOST: "mqtt"
      MQTT_BROKER_PORT: 1883
      MQTT_TOPIC: "processed_data_topic"
      BATCH_SIZE: 20
    ports:
      - "9000:8000"
    networks:
      mqtt_network:
      hub_store:
      hub_redis:

networks:
  mqtt_network:
  db_network:
  edge_hub:
  hub:
  hub_store:
  hub_redis:


volumes:
  postgres_data:
  pgadmin-data:
