version: '3.1'

services:

  wordpress:
    image: wordpress:${LOCAL_WP-5.9}-php${LOCAL_PHP-7.4}
    container_name: wp-crontrol-wordpress
    restart: always
    ports:
      - 80
    environment:
      WORDPRESS_DB_HOST: mysql
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
      WORDPRESS_DEBUG: ${LOCAL_WP_DEBUG-1}
      WORDPRESS_CONFIG_EXTRA: |
        define( 'WP_DEBUG_DISPLAY', true );
    user: "33:33"
    depends_on:
      - mysql
    volumes:
      - wp:/var/www/html:rw
      - ./:/var/www/html/wp-content/plugins/wp-crontrol

  mysql:
    image: mariadb:10.5.8
    container_name: wp-crontrol-mysql
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - mysql:/var/lib/mysql:rw

  wpcli:
    image: wordpress:cli-php${LOCAL_PHP-7.4}
    container_name: wp-crontrol-wpcli
    environment:
      WORDPRESS_DB_HOST: mysql
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    user: "33:33"
    depends_on:
      - mysql
      - wordpress
    init: true
    volumes:
      - wp:/var/www/html:rw
      - ./:/var/www/html/wp-content/plugins/wp-crontrol

  chrome:
    image: ${CHROME_IMAGE-selenium/standalone-chrome}
    container_name: wp-crontrol-chrome
    restart: always
    ports:
      - 4444
    extra_hosts:
      - host.docker.internal:host-gateway
    shm_size: 2gb

volumes:
  wp:
  mysql:
