version: '3'

services:
  db:
    image: mysql:latest
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: wordpress-root
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

  wordpress:
    depends_on:
      - db
    image: wordpress:5.5-php7.4-apache
    ports:
      - "8080:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_TABLE_PREFIX: wp
      WORDPRESS_DEBUG: 1
    working_dir: /var/www/html
    volumes:
      - wp_data:/var/www/html
      - ./:/var/www/html/wp-content/plugins/ga-germanized

  wordpress-cli:
    depends_on:
      - db
      - wordpress
    image: wordpress:cli
    restart: always
    user: xfs
    command: >
      /bin/sh -c '
      wp core install --path="/var/www/html" --url="http://localhost:8080" --title="GA Germanized" --admin_user=admin --admin_password=admin --admin_email=foo@example.com;
      wp plugin activate ga-germanized;
      '
    volumes:
      - wp_data:/var/www/html

volumes:
  db_data:
  wp_data: