---
application_id: "web-app-discourse"
entity_name: "{{ application_id | entity_name }}"
database_password: "{{ lookup('config', application_id, 'secrets.credentials.database_password') }}" # nocheck: lookup-config-path
DISCOURSE_CONTAINER: "{{ entity_name }}"
DISCOURSE_NETWORK: "{{ application_id | entity_name }}"
DISCOURSE_VOLUME: "{{ lookup('volume', application_id, 'data').name }}"
DISCOURSE_PLUGINS: "{{ lookup('config', application_id, 'addons') }}"
DISCOURSE_PG_NETWORK: "{{ ('svc-db-' ~ DISCOURSE_DATABASE_TYPE) | entity_name }}"
DISCOURSE_REDIS_NETWORK: "{{ 'svc-db-redis' | entity_name }}"
DISCOURSE_WEB_NETWORK: "{{ 'svc-prx-openresty' | entity_name }}"
DISCOURSE_REDIS_SHARED: "{{ not (lookup('engine', 'redis', application_id, 'local') | bool) }}"
DISCOURSE_REDIS_HOST: "{{ lookup('engine', 'redis', application_id, 'host') }}"
DISCOURSE_REDIS_PORT: "{{ lookup('engine', 'redis', application_id, 'port') }}"
DISCOURSE_REDIS_PASSWORD: "{{ lookup('engine', 'redis', application_id, 'password') }}"
DISCOURSE_REPOSITORY_URL: "{{ lookup('config', application_id, 'services.' ~ entity_name ~ '.repository') }}"
DISCOURSE_REF: "{{ lookup('config', application_id, 'services.' ~ entity_name ~ '.ref') }}"
DISCOURSE_VERSION: "{{ lookup('config', application_id, 'services.' ~ entity_name ~ '.application.ref') }}"
DISCOURSE_UNICORN_WORKERS: "{{ [[[2 * (RESOURCE_HOST_CPUS | int), (lookup('resource', 'host_mem_mb') | int) // 4096] | min, 2] | max, 8] | min }}"
DISCOURSE_DATABASE: "{{ lookup('database', application_id ) }}"
DISCOURSE_DATABASE_TYPE: "{{ DISCOURSE_DATABASE.type }}"
DISCOURSE_DATABASE_CONTAINER: "{{ DISCOURSE_DATABASE.container }}" # nocheck: container-var-name-lookup references the shared database container, not this role's service
DISCOURSE_DATABASE_IS_SHARED: "{{ DISCOURSE_DATABASE.shared }}"
DISCOURSE_SERVICES_DIR: "{{ lookup('container', application_id, 'directories.services') }}"
DISCOURSE_REPOSITORY_DIR: "{{ [ DISCOURSE_SERVICES_DIR, 'discourse_docker' ] | path_join }}"
DISCOURSE_REPOSITORY_LEGACY_RELPATH: "{{ (DISCOURSE_SERVICES_DIR ~ DISCOURSE_REPOSITORY_URL) | relpath(DISCOURSE_SERVICES_DIR) }}"
DISCOURSE_CONTAINERS_DIR: "{{ [ DISCOURSE_REPOSITORY_DIR, 'containers' ] | path_join }}"
DISCOURSE_APPLICATION_YML_DEST: "{{ [ DISCOURSE_CONTAINERS_DIR, DISCOURSE_CONTAINER ~ '.yml' ] | path_join }}"
DISCOURSE_BOOTSTRAP_DIGEST_DEST: "{{ [ DISCOURSE_CONTAINERS_DIR, DISCOURSE_CONTAINER ~ '.bootstrap.sha256' ] | path_join }}"
DISCOURSE_NETWORK_PLUGIN_HOST_DIR: "{{ [ lookup('container', application_id, 'directories.volumes'), 'plugins', 'infinito-network-origins' ] | path_join }}"
DISCOURSE_NETWORK_BASE_URLS: "{{ lookup('network_urls', lookup('tls', application_id, 'url.base')) }}"
DISCOURSE_LDAP_ENABLED: "{{ lookup('config', application_id, 'services.ldap.enabled') }}"
DISCOURSE_LITELLM_ENABLED: "{{ lookup('config', application_id, 'services.litellm.enabled') | bool }}"
DISCOURSE_LITELLM_API_KEY: "{{ lookup('config', application_id, 'secrets.credentials.litellm_api_key') }}"
DISCOURSE_LITELLM_NETWORK: "{{ 'svc-ai-litellm' | entity_name }}"
DISCOURSE_LITELLM_HOST: "{{ LITELLM_OPENAI_BASE_LOCAL_URL | urlsplit('hostname') }}"
DISCOURSE_LITELLM_CHAT_ENDPOINT: "{{ LITELLM_OPENAI_BASE_LOCAL_URL }}/chat/completions"
DISCOURSE_TRANSLATE_ENABLED: "{{ lookup('config', application_id, 'services.translate.enabled') | bool }}"
DISCOURSE_TRANSLATE_PROVIDER: "{{ lookup('config', application_id, 'addons.discourse-translator.config.provider') }}"
DISCOURSE_TRANSLATE_NETWORK: "{{ 'web-svc-translate' | entity_name }}"
DISCOURSE_TRANSLATE_ENDPOINT: "{{ lookup('container_url', 'web-svc-translate', 'translate') }}"
DISCOURSE_TRANSLATE_HOST: "{{ DISCOURSE_TRANSLATE_ENDPOINT | urlsplit('hostname') }}"
DISCOURSE_MERMAID_ENABLED: "{{ lookup('config', application_id, 'addons.discourse-mermaid.enabled') | bool }}"
DISCOURSE_MERMAID_REPOSITORY: "{{ lookup('config', application_id, 'addons.discourse-mermaid.config.repository') }}"
DISCOURSE_MERMAID_REF: "{{ lookup('config', application_id, 'addons.discourse-mermaid.config.ref') }}"
DISCOURSE_CHAT_INTEGRATION_ENABLED: "{{ lookup('config', application_id, 'addons.discourse-chat-integration.enabled') | bool }}"
DISCOURSE_CHAT_INTEGRATION_SETTINGS: "{{ ['chat_integration_enabled'] + (['chat_integration_matrix_enabled'] if lookup('config', application_id, 'services.matrix.enabled')
| bool else []) + (['chat_integration_mattermost_enabled'] if lookup('config', application_id, 'services.mattermost.enabled') | bool else []) }}"
DISCOURSE_AI_LLM_DISPLAY_NAME: "{{ lookup('config', application_id, 'addons.discourse-ai.config.display_name') }}"
DISCOURSE_AI_MAX_PROMPT_TOKENS: "{{ lookup('config', application_id, 'addons.discourse-ai.config.max_prompt_tokens') | int }}"
DISCOURSE_LOCAL: "C.{{ HOST_CS }}"
DISCOURSE_OIDC_ENABLED: "{{ lookup('config', application_id, 'services.sso.enabled') }}"
DISCOURSE_OIDC_LOGOUT_REDIRECT_URL: "{{ lookup('tls', 'web-svc-logout', 'url.base') }}"
DISCOURSE_LOCAL_LOGIN_ENABLED: "{{ lookup('config', application_id, 'services.discourse.local_login_enabled') }}"
DISCOURSE_SITE_SETTINGS: "{{ lookup('config', application_id, 'services.discourse.site_settings') | combine(DISCOURSE_PLUGINS['discourse-ldap-auth'].config.site_settings
if DISCOURSE_LDAP_ENABLED | bool else {}) }}"
DISCOURSE_DESIGN_ENABLED: "{{ lookup('config', application_id, 'services.design.enabled') | bool }}"
DISCOURSE_DESIGN_LOGO_ENABLED: "{{ DISCOURSE_DESIGN_ENABLED | bool and lookup('design', application_id).logo is string }}"
DISCOURSE_DESIGN_DIR: "{{ [lookup('container', application_id, 'directories.config'), 'design'] | path_join }}"
DISCOURSE_DESIGN_MARK: "infinito_design"
DISCOURSE_DESIGN_SCHEME_LIGHT: "Infinito.Nexus Light"
DISCOURSE_DESIGN_SCHEME_DARK: "Infinito.Nexus Dark"
DISCOURSE_DESIGN_COMPONENT: "Infinito.Nexus Design"
DISCOURSE_DESIGN_PALETTE: "{{ lookup('design_palette', lookup('config', 'web-svc-design', 'services.design.colors.base')) }}"
DISCOURSE_DESIGN_COLOR_TOKENS:
primary: "--design-text"
secondary: "--design-surface-1"
tertiary: "--design-link"
quaternary: "--design-primary"
header_background: "--design-frame"
header_primary: "--design-on-frame"
highlight: "--design-warning-subtle"
selected: "--design-surface-active"
hover: "--design-surface-hover"
danger: "--design-danger"
success: "--design-success"
love: "--design-danger"
primary_very_low: "--design-surface-3"
primary_low: "--design-border"
primary_low_mid: "--design-border-strong"
primary_medium: "--design-text-muted"
primary_high: "--design-text-muted"
DISCOURSE_DESIGN_COLORS_LIGHT: "{{ dict(DISCOURSE_DESIGN_COLOR_TOKENS.keys() | zip(DISCOURSE_DESIGN_COLOR_TOKENS.values() | map('extract', DISCOURSE_DESIGN_PALETTE.light)))
if DISCOURSE_DESIGN_ENABLED | bool else {} }}"
DISCOURSE_DESIGN_COLORS_DARK: "{{ dict(DISCOURSE_DESIGN_COLOR_TOKENS.keys() | zip(DISCOURSE_DESIGN_COLOR_TOKENS.values() | map('extract', DISCOURSE_DESIGN_PALETTE.dark)))
if DISCOURSE_DESIGN_ENABLED | bool else {} }}"
DISCOURSE_DESIGN_SCSS: "{{ lookup('file', 'scss/design.scss') if DISCOURSE_DESIGN_ENABLED | bool else '' }}"
DISCOURSE_DESIGN_TITLE: "{{ lookup('design', application_id).title if DISCOURSE_DESIGN_ENABLED | bool and lookup('design', application_id).title is string else ''
}}"
DISCOURSE_DESIGN_UPLOADS:
logo: logo.png
logo_small: logo-small.png
favicon: favicon.png
apple_touch_icon: apple-touch-icon.png
large_icon: large-icon.png
DISCOURSE_TLS_ENABLED: "{{ lookup('tls', application_id, 'enabled') | bool }}"
DISCOURSE_TLS_SELFSIGNED: "{{ lookup('tls', application_id, 'mode') == 'self_signed' }}"
DISCOURSE_TLS_SELFSIGNED_ENABLED: "{{ ( DISCOURSE_TLS_ENABLED | bool ) and ( DISCOURSE_TLS_SELFSIGNED | bool ) }}"