services:
  # MySQL Database
  mysql:
    image: mysql:8.0
    container_name: rezepte_mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: rezepte123
      MYSQL_DATABASE: rezepte_klaus
      MYSQL_USER: rezepte_user
      MYSQL_PASSWORD: rezepte_pass
    ports:
      - "3307:3306"
    volumes:
      - mysql_data:/var/lib/mysql
      - ./sql-init:/docker-entrypoint-initdb.d
    networks:
      - rezepte_network

  # PHP Application with Apache
  php-app:
    build: .
    container_name: rezepte_app
    restart: always
    ports:
      - "8082:80"
    volumes:
      - .:/var/www/html
    depends_on:
      - mysql
    networks:
      - rezepte_network
    environment:
      DB_HOST: mysql
      DB_NAME: rezepte_klaus
      DB_USER: rezepte_user
      DB_PASS: rezepte_pass

  # phpMyAdmin
  phpmyadmin:
    image: phpmyadmin:latest
    container_name: rezepte_phpmyadmin
    restart: always
    ports:
      - "8083:80"
    environment:
      PMA_HOST: mysql
      PMA_USER: rezepte_user
      PMA_PASSWORD: rezepte_pass
      MYSQL_ROOT_PASSWORD: rezepte123
    depends_on:
      - mysql
    networks:
      - rezepte_network

volumes:
  mysql_data:

networks:
  rezepte_network:
    driver: bridge