# This is the Compose file for command-line services.
# Anything that doesn't need to be run as part of the main `docker-compose up'
# command should reside in here and be invoked by a helper script.
version: "3.7"

services:
  app:
    image: ghcr.io/ndigitals/wp-dev-container:php-8.0-node-16
    restart: always
    depends_on:
      - db
      - phpmyadmin
      - web
      - mailhog
    working_dir: /workspaces/openid-connect-generic
    environment: &env
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_TEST_DB_NAME: wordpress_test
      CODESPACES: "${CODESPACES}"
      CODESPACE_NAME: "${CODESPACE_NAME}"
      GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN: "${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
    volumes:
      - .:/workspaces/openid-connect-generic:cached
      - ./tools/local-env:/app:cached
      - ./tools/php/php-cli.ini:/usr/local/etc/php/php-cli.ini:ro,cached
      - .:/app/wp-content/plugins/daggerhart-openid-connect-generic:ro,cached
      - ~/.composer:/root/.composer:cached
      - ~/.npm:/root/.npm:cached
    networks:
      - oidcwp-net

  web:
    image: httpd
    restart: unless-stopped
    depends_on:
      - db
    ports:
      - 8080:80
    environment:
      <<: *env
    volumes:
      - ./tools/local-env:/app:cached
      - .:/app/wp-content/plugins/daggerhart-openid-connect-generic:ro,cached
      - ./tools/apache/httpd.conf:/usr/local/apache2/conf/httpd.conf:ro,cached
    networks:
      - oidcwp-net

  db:
    image: mariadb
    restart: unless-stopped
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    volumes:
      - db:/var/lib/mysql
      - ./tests/db-wordpress_test.sql:/docker-entrypoint-initdb.d/db-wordpress_test.sql
    networks:
      - oidcwp-net

  phpmyadmin:
    image: phpmyadmin
    restart: unless-stopped
    depends_on:
      - db
    ports:
      - 8081:8081
    environment:
      PMA_HOST: db
      APACHE_PORT: 8081
    networks:
      - oidcwp-net

  ## SMTP Server + Web Interface for viewing and testing emails during development.
  mailhog:
    image: mailhog/mailhog
    restart: unless-stopped
    ports:
      - 1025:1025 # smtp server
      - 8026:8025 # web ui
    networks:
      - oidcwp-net

volumes:
  db:

networks:
  oidcwp-net:

