#
#   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'
services:
  dd-sso-admin:
    container_name: dd-sso-admin
    image: registry.dd-work.space/dd/sso-admin:${DD_BUILD:-latest}
    build:
      context: ${BUILD_SSO_ROOT_PATH}
      dockerfile: admin/docker/Dockerfile
      target: production
    networks:
      - dd_net
    restart: unless-stopped
    volumes:
    - /etc/localtime:/etc/localtime:ro
    - ${BUILD_SSO_ROOT_PATH}/init/keycloak/jsons:/admin/keycloak-init:ro
    - ${CUSTOM_PATH}/custom:/admin/custom:rw
    - ${DATA_FOLDER}/avatars:/admin/avatars:ro
    - ${DATA_FOLDER}/moodle/saml2:/admin/moodledata/saml2:rw
    - ${DATA_FOLDER}/saml/public:/admin/saml_certs:ro
    - ${DATA_FOLDER}/legal:/admin/admin/static/templates/pages/legal:rw
    - ${DATA_FOLDER}/dd-admin:/data:rw
    - ${DATA_FOLDER}/nc-mail-queue:/nc-mail-queue:rw
    environment:
      - VERIFY="false"  # In development do not verify certificates
      - DOMAIN=${DOMAIN}
      - MANAGED_EMAIL_DOMAIN=${MANAGED_EMAIL_DOMAIN}
      - DATA_FOLDER=/data
      - CUSTOM_FOLDER=/admin/custom
      - NC_MAIL_QUEUE_FOLDER=/nc-mail-queue
      - LEGAL_PATH=/admin/admin/static/templates/pages/legal
      - PYTHONPATH=/admin
      - AVATARS_SERVER_HOST=dd-sso-avatars:9000
      - AVATARS_ACCESS_KEY=${AVATARS_ACCESS_KEY:-AKIAIOSFODNN7EXAMPLE}
      - AVATARS_SECRET_KEY=${AVATARS_SECRET_KEY:-wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY}
    # TODO: Check missing env vars and pass them on the environment
    env_file: ${CUSTOM_PATH}/.env
