services:
  dronedetector-server-to-master:
    container_name: dronedetector-server-to-master
    image: dronedetector-server-to-master:latest
    build:
      context: ../..
      dockerfile: deploy/docker/Dockerfile.server_to_master
    env_file:
      - ../../.env
    environment:
      - PYTHONPATH=/app
      - JAMMER_STATE_FILE=/app/runtime/jammer_active.flag
    working_dir: /app
    command: ["python3", "-m", "src.server_to_master"]
    restart: unless-stopped
    ports:
      - "5010:5010"
    volumes:
      - ../../.env:/app/.env:ro
      - ../../runtime:/app/runtime
    networks:
      - dronedetector-net

  dronedetector-nn-server:
    container_name: dronedetector-nn-server
    image: dronedetector-nn-server:latest
    build:
      context: ../..
      dockerfile: deploy/docker/Dockerfile.nn_server
    env_file:
      - ../../.env
    environment:
      - PYTHONPATH=/app:/app/NN_server
      - NN_HOT_RELOAD=${NN_HOT_RELOAD:-1}
    working_dir: /app/NN_server
    command:
      - sh
      - -lc
      - if [ "${NN_HOT_RELOAD:-1}" = "1" ]; then watchmedo auto-restart --recursive --patterns="*.py" --ignore-patterns="*/result/*" -- python3 server.py; else python3 server.py; fi
    restart: unless-stopped
    depends_on:
      - dronedetector-server-to-master
    ports:
      - "8080:8080"
    volumes:
      - ../../.env:/app/.env:ro
      - ../../NN_server:/app/NN_server
      - ../../common:/app/common
    gpus: all
    networks:
      - dronedetector-net


  dronedetector-telemetry-server:
    container_name: dronedetector-telemetry-server
    image: dronedetector-telemetry-server:latest
    build:
      context: ../..
      dockerfile: deploy/docker/Dockerfile.telemetry_server
    env_file:
      - ../../.env
    environment:
      - PYTHONPATH=/app
    working_dir: /app
    command: ["python3", "-m", "telemetry.telemetry_server"]
    restart: unless-stopped
    ports:
      - "5020:5020"
    volumes:
      - ../../.env:/app/.env:ro
      - ../../telemetry:/app/telemetry
      - ../../common:/app/common
    networks:
      - dronedetector-net

networks:
  dronedetector-net:
    name: dronedetector-net
