version: '3.8'
services:
    app:
      build:
        context: .
        dockerfile: Dockerfile
      container_name: 5questions_app
      depends_on:
        - db  
      ports:
        - "8080:80" # Accéder à l'application via http://localhost:8080
      volumes:
        - ./config:/etc/apache2/sites-enabled
        - ./:/var/www
      env_file:
        - service_5questions/.env
      environment:
        - APACHE_DOCUMENT_ROOT=/var/www/html/project # Définir le document root


    db:
      image: mysql/mysql-server:8.0
      container_name: mysql_db
      restart: always
      environment:
        MYSQL_DATABASE: 'quiz'
        MYSQL_ROOT_PASSWORD: 'root'
        MYSQL_USER: myuser
        MYSQL_PASSWORD: mypassword
      ports:
        - '3306:3306'
      command: --default-authentication-plugin=mysql_native_password
      volumes:
        - db_data:/var/lib/mysql  # <-- Ajout d’un volume persistant

volumes:
  db_data: