# ===================
# Anagram Finder Web - Development Services
# ===================
# Port allocation:
#   App:   8001 (frankenphp), 5174 (vite)
#   DB:    3308 (mariadb)

services:
  app:
    build:
      context: ../..
      dockerfile: Dockerfile.dev
    container_name: anagram_web_dev_app
    restart: unless-stopped
    ports:
      - "8001:8000"
      - "5174:5173"
    volumes:
      - ../..:/app
    environment:
      APP_NAME: "Anagram Finder"
      APP_ENV: "${APP_ENV:-local}"
      APP_DEBUG: "${APP_DEBUG:-true}"
      APP_URL: "${APP_URL:-http://localhost:8001}"
      DB_CONNECTION: mariadb
      DB_HOST: db
      DB_PORT: 3306
      DB_DATABASE: "${DB_DATABASE:-anagram_dev}"
      DB_USERNAME: "${DB_USERNAME:-anagram}"
      DB_PASSWORD: "${DB_PASSWORD:-anagram}"
      SESSION_DRIVER: database
      CACHE_STORE: database
      QUEUE_CONNECTION: database
      VITE_HOST: "0.0.0.0"
    depends_on:
      db:
        condition: service_healthy
    networks:
      - anagram-network

  db:
    image: mariadb:11
    container_name: anagram_web_dev_db
    restart: unless-stopped
    ports:
      - "3308:3306"
    environment:
      MARIADB_DATABASE: "${DB_DATABASE:-anagram_dev}"
      MARIADB_USER: "${DB_USERNAME:-anagram}"
      MARIADB_PASSWORD: "${DB_PASSWORD:-anagram}"
      MARIADB_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:-anagram_root_dev}"
    volumes:
      - db_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s
    networks:
      - anagram-network

networks:
  anagram-network:
    driver: bridge

volumes:
  db_data:
