services:
  web:
    build: .
    ports:
      - "5000:5000"
    volumes:
      - .:/app
      - ./static/uploads:/app/static/uploads
    environment:
      - FLASK_APP=app
      - FLASK_ENV=development
      - USE_REMOTE_MYSQL=${USE_REMOTE_MYSQL}
      - ENABLE_DB_SEEDING=${ENABLE_DB_SEEDING}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_HOST=${MYSQL_HOST}
      - MYSQL_PORT=${MYSQL_PORT}
    depends_on:
      - db
    healthcheck:
      test: ["CMD-SHELL", "curl -fs http://127.0.0.1:5000/health || exit 1"]
      interval: 10s
      timeout: 3s
      retries: 3
      start_period: 30s

  db:
    image: mysql:8
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    ports:
      - "42000:3306"
    volumes:
      - plant_price_tracker_mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080
    environment:
      ADMINER_DEFAULT_SERVER: db
    depends_on:
      - db

  neo4j:
    image: neo4j:5.18
    container_name: nip_neo4j
    ports:
      - '7474:7474'
      - '7687:7687'
    environment:
      - NEO4J_AUTH=neo4j/your_secure_password
    volumes:
      - neo4j_data:/data

volumes:
  plant_price_tracker_mysql_data:
  neo4j_data:
