services:
  db:
    image: mariadb:10.5
    platform: linux/arm64/v8
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=${DEV_DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=${DEV_DB_NAME}
      - MYSQL_USER=${DEV_DB_USER}
      - MYSQL_PASSWORD=${DEV_DB_PASSWORD}
    ports:
      - "3306:3306"

  wordpress:
    depends_on:
      - db
    image: wordpress:6.7.2-php8.1-fpm
    platform: linux/arm64/v8
    volumes:
      - ./wordpress:/var/www/html
      - ./vendor:/var/www/html/vendor # Restore host vendor mount (removed :cached)
      - ./tests:/var/www/html/tests:cached
      - ./phpunit.xml.dist:/var/www/html/phpunit.xml.dist:cached
      - ./wp-tests-config.php:/var/www/html/wp-tests-config.php:cached # Mount the correct test config
      - ./bin/wp-cli.phar:/usr/local/bin/wp # Mount WP-CLI phar directly
      - ./php.ini/custom.ini:/usr/local/etc/php/conf.d/custom.ini # Corrected mount: file to file
      - ./php-fpm.conf:/usr/local/etc/php-fpm.d/www.conf
    restart: always
    environment:
      - WORDPRESS_DB_HOST=db
      - WORDPRESS_DB_USER=${DEV_DB_USER}
      - WORDPRESS_DB_PASSWORD=${DEV_DB_PASSWORD}
      - WORDPRESS_DB_NAME=${DEV_DB_NAME}
      - WORDPRESS_DEBUG=1

  nginx:
    depends_on:
      - wordpress
    image: nginx:alpine
    platform: linux/arm64/v8
    ports:
      - "${WORDPRESS_PORT}:80"
      - "${WORDPRESS_SSL_PORT}:443"
    volumes:
      - ./wordpress:/var/www/html
      - ./nginx-conf:/etc/nginx/conf.d
      - ./ssl:/etc/nginx/ssl
    restart: always

  phpmyadmin:
    depends_on:
      - db
    image: arm64v8/phpmyadmin:latest
    restart: always
    ports:
      - "${PHPMYADMIN_PORT}:80"
    environment:
      - PMA_HOST=db
      - MYSQL_ROOT_PASSWORD=${DEV_DB_ROOT_PASSWORD}

volumes:
  db_data:
  wordpress_data: