version: '3.7'
services:
  wordpress-develop:
    depends_on:
      - php
      - mailhog

    environment:
      LOCAL_DIR: ${LOCAL_DIR-src}
      SMTP_HOST: ${SMTP_HOST-mailhog}
      SMTP_PORT: ${SMTP_PORT-1025}

    volumes:
      - ../tools/local-env/default.template:/etc/nginx/conf.d/default.template
      - ..:/var/www/${LOCAL_DIR-src}/wp-content/plugins/daggerhart-openid-connect-generic
      - ../tools/local-env/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins

    # Load our config file, substituning environment variables into the config.
    command: /bin/sh -c "envsubst '$$LOCAL_DIR $$LOCAL_HOSTNAME' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"

  php:
    environment:
      LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
      LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}
      PHP_FPM_UID: ${PHP_FPM_UID-1000}
      PHP_FPM_GID: ${PHP_FPM_GID-1000}
      SMTP_HOST: ${SMTP_HOST-mailhog}
      SMTP_PORT: ${SMTP_PORT-1025}

    volumes:
      - ..:/var/www/${LOCAL_DIR-src}/wp-content/plugins/daggerhart-openid-connect-generic/
      - ../tools/local-env/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins

  cli:
    environment:
      LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
      LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}
      PHP_FPM_UID: ${PHP_FPM_UID-1000}
      PHP_FPM_GID: ${PHP_FPM_GID-1000}
      SMTP_HOST: ${SMTP_HOST-mailhog}
      SMTP_PORT: ${SMTP_PORT-1025}

    volumes:
      - ..:/var/www/${LOCAL_DIR-src}/wp-content/plugins/daggerhart-openid-connect-generic/
      - ../tools/local-env/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins

  phpunit:
    environment:
      LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
      LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}
      LOCAL_DIR: ${LOCAL_DIR-src}
      WP_MULTISITE: ${WP_MULTISITE-false}
      PHP_FPM_UID: ${PHP_FPM_UID-1000}
      PHP_FPM_GID: ${PHP_FPM_GID-1000}
      TRAVIS_BRANCH: ${TRAVIS_BRANCH-false}
      TRAVIS_PULL_REQUEST: ${TRAVIS_PULL_REQUEST-false}
      SMTP_HOST: ${SMTP_HOST-mailhog}
      SMTP_PORT: ${SMTP_PORT-1025}

    volumes:
      - ..:/var/www/${LOCAL_DIR-src}/wp-content/plugins/daggerhart-openid-connect-generic/
      - ../tools/local-env/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins

  ## SMTP Server + Web Interface for viewing and testing emails during development.
  mailhog:
    image: mailhog/mailhog

    restart: always

    networks:
      - wpdevnet

    ports:
      - "${MAILHOG_PORT:-8025}:8025"
      - "${SMTP_PORT:-1025}:1025"
