# ===================
# FFR Development Services
# ===================
# Port allocation:
#   App:   8000 (frankenphp), 5173 (vite)
#   DB:    3307 (mysql)
#   Redis: 6380

services:
  app:
    build:
      context: ../..
      dockerfile: Dockerfile.dev
    container_name: ffr_dev_app
    restart: unless-stopped
    ports:
      - "8000:8000"
      - "5173:5173"
    volumes:
      - ../..:/app
    environment:
      APP_NAME: "FFR"
      APP_ENV: "${APP_ENV:-local}"
      APP_DEBUG: "${APP_DEBUG:-true}"
      APP_URL: "${APP_URL:-http://localhost:8000}"
      DB_CONNECTION: mysql
      DB_HOST: db
      DB_PORT: 3306
      DB_DATABASE: "${DB_DATABASE:-ffr_dev}"
      DB_USERNAME: "${DB_USERNAME:-ffr}"
      DB_PASSWORD: "${DB_PASSWORD:-ffr}"
      REDIS_HOST: redis
      REDIS_PORT: 6379
      SESSION_DRIVER: redis
      CACHE_STORE: redis
      QUEUE_CONNECTION: redis
      VITE_HOST: "0.0.0.0"
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
    networks:
      - ffr-network

  db:
    image: mariadb:11
    container_name: ffr_dev_db
    restart: unless-stopped
    ports:
      - "3307:3306"
    environment:
      MYSQL_DATABASE: "${DB_DATABASE:-ffr_dev}"
      MYSQL_USER: "${DB_USERNAME:-ffr}"
      MYSQL_PASSWORD: "${DB_PASSWORD:-ffr}"
      MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:-ffr_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:
      - ffr-network

  redis:
    image: redis:7-alpine
    container_name: ffr_dev_redis
    restart: unless-stopped
    ports:
      - "6380:6379"
    networks:
      - ffr-network

networks:
  ffr-network:
    driver: bridge

volumes:
  db_data:
