services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: wedding-app:latest
    container_name: wedding_app
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - ./:/var/www/html
    networks:
      - wedding_network
    depends_on:
      - db

  webserver:
    image: nginx:alpine
    container_name: wedding_webserver
    restart: unless-stopped
    ports:
      - "8000:80"
    volumes:
      - ./:/var/www/html
      - ./docker/nginx:/etc/nginx/conf.d
    networks:
      - wedding_network
    depends_on:
      - app

  db:
    image: mysql:8.0
    container_name: wedding_db
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${DB_DATABASE:-wedding_guest_management}
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-root}
      MYSQL_PASSWORD: ${DB_PASSWORD:-password}
      MYSQL_USER: ${DB_USERNAME:-wedding_user}
    ports:
      - "3306:3306"
    volumes:
      - wedding_db_data:/var/lib/mysql
    networks:
      - wedding_network

  worker:
    image: wedding-app:latest
    container_name: wedding_worker
    restart: unless-stopped
    working_dir: /var/www/html
    command: bash -c "php artisan queue:work --sleep=3 --tries=3 & php artisan schedule:work"
    volumes:
      - ./:/var/www/html
    networks:
      - wedding_network
    depends_on:
      - app
      - db

  phpmyadmin:
    image: phpmyadmin:latest
    container_name: wedding_phpmyadmin
    restart: unless-stopped
    ports:
      - "8080:80"
    environment:
      PMA_HOST: db
      PMA_PORT: 3306
      PMA_USER: root
      PMA_PASSWORD: ${DB_ROOT_PASSWORD:-root}
    networks:
      - wedding_network
    depends_on:
      - db

networks:
  wedding_network:
    driver: bridge

volumes:
  wedding_db_data:
    driver: local
