#
#   Copyright © 2021,2022 IsardVDI S.L.
#
#   This file is part of DD
#
#   DD is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or (at your
#   option) any later version.
#
#   DD is distributed in the hope that it will be useful, but WITHOUT ANY
#   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
#   FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
#   details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with DD. If not, see <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: AGPL-3.0-or-later
version: '3.7'

x-volumes:
  &wordpress-volumes
  - /etc/localtime:/etc/localtime:ro
  - ${BUILD_APPS_ROOT_PATH}/docker/wordpress/src/config/php.conf.ini:/usr/local/etc/php/conf.d/conf.ini
  - ${SRC_FOLDER}/wordpress:/var/www/html
  - ${DATA_FOLDER}/saml/wordpress:/saml:ro
  - ${BUILD_APPS_ROOT_PATH}/docker/wordpress/plugins:/plugins
  - ${BUILD_APPS_ROOT_PATH}/docker/wordpress/.htaccess:/var/www/html/.htaccess:ro
  - ${DATA_FOLDER}/wordpress:/var/www/html/wp-content/uploads

services:
  dd-apps-wordpress:
    image: ${WORDPRESS_IMG}
    container_name: dd-apps-wordpress
    volumes:
      *wordpress-volumes
    environment:
      DOMAIN: ${DOMAIN}
      WORDPRESS_DB_HOST: dd-apps-mariadb
      WORDPRESS_DB_NAME: "wordpress"
      WORDPRESS_DB_USER: ${WORDPRESS_MARIADB_USER}
      WORDPRESS_DB_PASSWORD: ${WORDPRESS_MARIADB_PASSWORD}
      WORDPRESS_DOMAIN_CURRENT_SITE: wp.${DOMAIN}
    depends_on:
      - dd-apps-mariadb
    links:
      - dd-apps-mariadb
    restart: unless-stopped
    healthcheck:
        test: |
          curl \
            --proxy-basic 'http://localhost' \
            -sw '%{redirect_url}' \
            'https://wp.${DOMAIN}/' | grep -q 'https://sso.${DOMAIN}'
        interval: 30s
        timeout: 10s
        retries: 5
    networks:
      - dd_net