version: "3.8"

services:

  app:
    build: .
    container_name: whatsapp_saas_app
    platform: linux/amd64
    ports:
      - "3003:3003"
    environment:
      - DB_HOST=163.172.68.103     # <- IP externe du serveur MariaDB
      - DB_PORT=3306
      - DB_USER=cangui@localhost
      - DB_PASS=GHT30k7!
      - DB_NAME=whatsapp_saas
      - ENV=dev
      - WHATSAPP_TOKEN=${WHATSAPP_TOKEN}
      - WHATSAPP_PHONE_NUMBER_ID=${WHATSAPP_PHONE_NUMBER_ID}
      - WHATSAPP_WEBHOOK_TOKEN=${WHATSAPP_WEBHOOK_TOKEN}
    volumes:
      - ./frontend/templates:/app/frontend/templates
      - ./frontend/assets:/app/frontend/assets
    depends_on:
      - db

  db:
    image: mariadb:10.6
    container_name: whatsapp_saas_db
    restart: always
    environment:
      MARIADB_ROOT_PASSWORD: secret
      MARIADB_DATABASE: whatsapp_saas
    # ❌ ports supprimé car 3306 déjà utilisé
    volumes:
      - db_data:/var/lib/mysql

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: whatsapp_saas_phpmyadmin
    restart: always
    environment:
      PMA_HOST: db
      PMA_PORT: 3306
      PMA_USER: root
      PMA_PASSWORD: secret
    ports:
      - "8081:80"
    depends_on:
      - db

volumes:
  db_data:
