# Lehrplan-Service zur Bereitstellung von Lehrplandaten
networks:
  nw-letto:
    external: true

# Der Name bestimmt das Projekt und sollte bei jeder yml-Datei unterschiedlich sein - er kann mit -p bei docker-compose überschrieben werden
name: letto-lehrplan

services:
  # Lehrplan-Service
  lehrplan:
    image: lettohub/letto-service-lehrplan:stable
    restart: always
    networks:
      - nw-letto
    deploy:
      resources:
        limits:
          memory: "${EDIT_MEMORY_LIMIT:-1G}"
    logging:
      driver: "json-file"
      options:
        max-size: "2m"
        max-file: "3"
    hostname: letto-lehrplan
    container_name: letto-lehrplan
    volumes:
      - ${VOLUME_LOG:-/opt/letto/docker/storage/log}/lehrplan:/log
    environment:
      - TZ=${TIMEZONE:-Europe/Berlin}
      - LC_ALL=${LOCALE:-de_DE.UTF-8}
      - UNHEALTHY_RETRIES=${LEHRPLAN_UNHEALTHY_RETRIES:-${UNHEALTHY_RETRIES:-20}}
      - spring_datasource_url=jdbc:mysql://${LETTO_LEHRPLAN_HOST:-letto-mysql.nw-letto:3306}/${LETTO_LEHRPLAN_DATABASE:-letto_lehrplan}?${LETTO_LEHRPLAN_PARS:-useSSL=false&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC}
      - spring_datasource_username=${LETTO_LEHRPLAN_USER:-root}
      - spring_datasource_password=${MYSQL_ROOT_PASSWORD}
      - jwt_secret=${JWT_SECRET:-YWJj}
      - server_secret=${SERVER_SECRET:-YWJj}
      - letto_log=/log
      - letto_user_user_password=${SERVICE_USER_PASSWORD}
      - letto_user_gast_password=${SERVICE_GAST_PASSWORD}
      - letto_user_admin_password=${SERVICE_ADMIN_PASSWORD}
      - letto_setup_uri=${LETTO_SETUP_URI:-http://letto-setup.nw-letto:8096}
      - letto_login_uri=${LETTO_LOGIN_URI:-http://letto-login.nw-letto:8095}
      - JAVA_OPTS=${JAVA_OPTS_EDIT:--Xms50m -Xmx300m}
      - REDIS_PASSWORD=${REDIS_PASSWORD:-${MYSQL_ROOT_PASSWORD}}
      - REDIS_DEFAULT_DATABASE=${LOGIN_REDIS_DEFAULT_DATABASE:-1}
      - MONGO_ROOT_PASSWORD=${MONGO_ROOT_PASSWORD:-${MYSQL_ROOT_PASSWORD}}
      - MONGO_DEFAULT_DATABASE=${LEHRPLAN_MONGO_DEFAULT_DATABASE:-lehrplan}
      - debug=${DEBUG_LEHRPLAN:-${DEBUG:-false}}
    ports:
    #  - "8104:8104"
      - "${DEBUG_PORT_LEHRPLAN:-5104}:5104"

  lehrplan-edit:
    image: lettohub/letto-lehrplan-edit:stable
    restart: always
    networks:
      - nw-letto
    deploy:
      resources:
        limits:
          memory: "${LETTO_MEMORY_LIMIT:-3G}"
    hostname: lehrplan-edit
    container_name: lehrplan-edit
    security_opt:
      - seccomp:unconfined
    logging:
      driver: "json-file"
      options:
        max-size: "2m"
        max-file: "3"
    healthcheck:
      test: [ "CMD", "bash", "/scripts/healthcheck.sh" ]
      interval: 1m30s
      timeout: 20s
      retries: 3
      start_period: 300s
    volumes:
      - ${VOLUME_LOG:-/opt/letto/docker/storage/log}/lehrplan:/opt/letto/log/lehrplan
    environment:
      - TZ=${TIMEZONE:-Europe/Berlin}
      - LC_ALL=${LOCALE:-de_DE.UTF-8}
      - UNHEALTHY_RETRIES=${LETTO_UNHEALTHY_RETRIES:-20}
      - mysqlhost=${LETTO_MYSQL_LEHRPLAN_HOST:-letto-mysql.nw-letto:3306}
      - mysqlpars=${LETTO_MYSQL_LEHRPLAN_PARS:-useSSL=false&amp;useUnicode=true&amp;useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC&amp;allowPublicKeyRetrieval=true}
      - memory=${LETTO_LEHRPLAN_MEMORY:-500M}
      - mysqluser=${LETTO_MYSQL_ROOT:-root}
      - mysqlpassword=${MYSQL_ROOT_PASSWORD}
      - letto_local_restkey=${LETTO_RESTKEY:-}
      - letto_jwt_secret=${JWT_SECRET:-YWJj}
      - letto_server_secret=${SERVER_SECRET:-YWJj}
      - letto_local_privatkey=${LETTO_LOCAL_PRIVATE_KEY:-}
      - letto_local_publickey=${LETTO_LOCAL_PUBLIC_KEY:-}
      - CATALINA_OPTS=${LETTO_LEHRPLAN_JAVA_OPTS:-${JAVA_OPTS_LETTO:--Xms500m -Xmx1G}}
      - debug=${DEBUG_LEHRPLAN_EDIT:-${DEBUG:-false}}
    ports:
      - "${DEBUG_PORT_LEHRPLAN_EDIT:-4190}:5080"
      - "${PORT_LEHRPLAN_EDIT:-8190}:8080"
