services:
  app:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    container_name: ai-trip-planner-app
    restart: unless-stopped
    working_dir: /var/www
    env_file:
      - ../.env
    volumes:
      - ../.env:/var/www/.env:ro
      - ../storage:/var/www/storage
      - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
    networks:
      - ai-trip-planner
    depends_on:
      - db
      - redis
    environment:
      - APP_ENV=production
      - APP_DEBUG=false
      - DB_HOST=db
      - DB_DATABASE=ai_trip_planner
      - DB_USERNAME=laravel
      - DB_PASSWORD=secret
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - REDIS_CLIENT=phpredis
    expose:
      - "9000"

  db:
    image: docker.io/mysql:8.0
    container_name: ai-trip-planner-db
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ai_trip_planner
      MYSQL_USER: laravel
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: root_secret
    volumes:
      - dbdata:/var/lib/mysql
      - ./mysql/my.cnf:/etc/mysql/my.cnf
    networks:
      - ai-trip-planner
    ports:
      - "3307:3306"
    command: --default-authentication-plugin=mysql_native_password

  nginx:
    image: docker.io/nginx:alpine
    container_name: ai-trip-planner-nginx
    restart: unless-stopped
    ports:
      - "8000:80"
    volumes:
      - ..:/var/www:ro
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    networks:
      - ai-trip-planner
    depends_on:
      - app

  redis:
    image: docker.io/redis:alpine
    container_name: ai-trip-planner-redis
    restart: unless-stopped
    networks:
      - ai-trip-planner
    ports:
      - "6380:6379"
    command: redis-server --appendonly yes
    volumes:
      - redisdata:/data

networks:
  ai-trip-planner:
    driver: bridge

volumes:
  dbdata:
    driver: local
  redisdata:
    driver: local
