services:
  lan_manager:
    build: .
    depends_on:
      db:
        condition: service_healthy
    environment:
      PYTHONPATH: /opt/ezgg-lan-manager
    ports:
      - "8000:8000"
      - "8001:8001"
    volumes:
      - ./:/opt/ezgg-lan-manager
    entrypoint: ["/bin/sh", "-c", "cd /opt/ezgg-lan-manager/src && python3 /opt/ezgg-lan-manager/src/EzggLanManager.py"]

  db:
    image: mariadb:latest
    environment:
      MARIADB_ROOT_PASSWORD: Alkohol1
      MARIADB_DATABASE: ezgg_lan_manager
      MARIADB_USER: ezgg_lan_manager
      MARIADB_PASSWORD: Alkohol1
    healthcheck:
      test: ["CMD", "mariadb-admin", "ping", "-h", "localhost", "-pAlkohol1"]
      interval: 5s
      timeout: 3s
      retries: 5
    ports:
      - "127.0.0.1:3306:3306"
    volumes:
      - database:/var/lib/mysql
      - ./sql/create_database.sql:/docker-entrypoint-initdb.d/init.sql
      - ./sql:/sql


volumes:
  database:
