version: '3.1'

services:
  php-apache:
    build:
      context: .  # The context where the Dockerfile is located
      dockerfile: Dockerfile  # Optional if Dockerfile is named 'Dockerfile'
    image: php:8.2-apache-custom  # Name of the custom image
    container_name: php-apache-server
    ports:
      - "8080:80"  # Maps host port 8080 to container's port 80
    volumes:
      - .:/var/www/html  # Mounts the local project directory to the container
      - vendor-volume:/var/www/html/vendor  # Separate volume for vendor folder so it's not overwritten
    restart: unless-stopped
    command: >
      bash -c "php /var/www/html/models/create_tables.php && apache2-foreground"
    environment:
      - APACHE_RUN_USER=www-data
      - APACHE_RUN_GROUP=www-data
      - APACHE_LOG_DIR=/var/log/apache2
      - dbservername=db
      - dbusername=root
      - dbpassword=pass
      - dbName=percuss4_login


  db:
    image: mysql
#    command: --default-authentication-plugin=mysql_native_password
    restart: always
    volumes:
      - ./data:/docker-entrypoint-initdb.d
    environment:
      MYSQL_ROOT_PASSWORD: pass
      MYSQL_DATABASE: percuss4_login
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    restart: always
    ports:
      - "8081:80"
    environment:
      - PMA_HOST=psp_db_1  # Connect to MySQL container
      - PMA_PORT=3306
      - PMA_USER=root
      - PMA_PASSWORD=pass
      - PMA_ARBITRARY=1
    depends_on:
      - db
volumes:
  vendor-volume:  # Define a named volume for vendor

