services:
  # PHP 8.4 with Apache
  web:
    container_name: agadir_web
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8080:80"
    volumes:
      - .:/var/www/html
    environment:
      - APACHE_DOCUMENT_ROOT=/var/www/html
      - DOCKER_ENV=development
    depends_on:
      - db
    networks:
      - agadir_network

  # MySQL 5.7 (compatible with existing database)
  db:
    image: mysql:5.7
    container_name: agadir_db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root_password_dev
      MYSQL_DATABASE: proamcottyapp
      MYSQL_USER: proamcottyapp
      MYSQL_PASSWORD: dev_password
    ports:
      - "3306:3306"
    volumes:
      - db_data:/var/lib/mysql
      - ./proamcottyapp.sql:/docker-entrypoint-initdb.d/init.sql
    networks:
      - agadir_network

  # phpMyAdmin for database management
  phpmyadmin:
    image: phpmyadmin:latest
    container_name: agadir_phpmyadmin
    restart: always
    ports:
      - "8081:80"
    environment:
      PMA_HOST: db
      PMA_USER: root
      PMA_PASSWORD: root_password_dev
    depends_on:
      - db
    networks:
      - agadir_network

volumes:
  db_data:

networks:
  agadir_network:
    driver: bridge
