services:
  # PHP & Laravel Application
  app:
    container_name: laravel_winary_app
    restart: unless-stopped
    working_dir: /var/www
    volumes:
      - ./:/var/www
    depends_on:
      - mysql
    networks:
      - winary_network
    env_file:
      - .env
    build:
      context: .
      dockerfile: Dockerfile.app

  # MySQL Service
  mysql:
    image: mysql:8.0
    container_name: laravel_winary_mysql
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_USER: ${DB_USERNAME}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
      SERVICE_NAME: mysql
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - winary_network
    ports:
      - "3306:3306"

  # phpMyAdmin Service
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: laravel_winary_phpmyadmin
    restart: unless-stopped
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
      PMA_USER: root
      PMA_PASSWORD: ${DB_ROOT_PASSWORD}
    depends_on:
      - mysql
    networks:
      - winary_network

# Volumes
volumes:
  mysql_data:
    driver: local

# Networks
networks:
  winary_network:
    driver: bridge
