# WordPress for the checks in ci/remote-check.sh that need a real site: Plugin Check (PLUGIN_DIR is the
# staged free plugin) and the WP-CLI tests in tests/cli (PLUGIN_DIR is the checkout; they run PHPUnit in
# the cli service, with Qdrant as the vector store).
# WP_IMAGE and CLI_IMAGE choose another WordPress and PHP (the defaults are the latest WordPress on PHP 8.3).
# Nothing is published to the host network.
services:
  db:
    image: mariadb:11.4
    environment:
      MARIADB_DATABASE: wordpress
      MARIADB_USER: wordpress
      MARIADB_PASSWORD: wordpress
      MARIADB_RANDOM_ROOT_PASSWORD: '1'
    healthcheck:
      test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized']
      interval: 2s
      retries: 30

  wordpress:
    image: ${WP_IMAGE:-wordpress:php8.3-apache}
    depends_on:
      db:
        condition: service_healthy
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
    volumes:
      - wp:/var/www/html
      - ${PLUGIN_DIR}:/var/www/html/wp-content/plugins/kimaai:ro
    healthcheck:
      test: ['CMD', 'test', '-f', '/var/www/html/wp-config.php']
      interval: 2s
      retries: 30

  # The vector store for the WP-CLI tests, reached as http://qdrant:6333. No volume: each run starts empty.
  qdrant:
    image: qdrant/qdrant:v1.20.0
    healthcheck:
      test: ['CMD', 'bash', '-c', ':> /dev/tcp/127.0.0.1/6333']
      interval: 2s
      retries: 30

  cli:
    image: ${CLI_IMAGE:-wordpress:cli-php8.3}
    # The apache image's www-data (33) owns the files; the cli image's default user differs.
    user: '33:33'
    depends_on:
      - wordpress
    # Ollama on the AI box itself, for the WP-CLI tests' AI calls.
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
    volumes:
      - wp:/var/www/html
      - ${PLUGIN_DIR}:/var/www/html/wp-content/plugins/kimaai:ro

volumes:
  wp:
