fix: do not add cairn-postgresql and cairn-clickhouse dependencies when they are running externally (#57)

* fix: don't add cairn-postgresql as a dependency when CAIRN_RUN_POSTGRESQL is false

* fix: don't manage cairn-clickhouse permissions CAIRN_RUN_CLICKHOUSE is false

* fix: add missing CAIRN_POSTGRESQL_HOST and CAIRN_POSTGRESQL_PORT settings to allow usage with external postgresql DBs
This commit is contained in:
Danyal Faheem 2025-03-14 17:48:06 +05:00 committed by GitHub
parent a6026d6f6b
commit 04f4275236
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 14 additions and 7 deletions

View File

@ -237,6 +237,8 @@ Postgresql/Superset settings
- ``CAIRN_RUN_POSTGRESQL`` (default: ``true``): set to ``false`` to run your own Postgresql cluster separately from Cairn. Postgresql is the database that stores all data related to Superset, which is the Cairn frontend.
- ``CAIRN_SUPERSET_LANGUAGE_CODE`` (default: ``"{{ LANGUAGE_CODE[:2] }}"``): 2-letter code of the default language for the Superset frontend. View the list of all supported languages `here <https://github.com/apache/superset/blob/dc575080d7e43d40b1734bb8f44fdc291cb95b11/superset/config.py#L324>`__. When different than "en", users will have the opportunity to switch from English to this language via a flag icon in the top-right corner.
- ``CAIRN_SUPERSET_DOCKER_IMAGE`` (default: ``"{{ DOCKER_REGISTRY }}overhangio/cairn-superset:{{ CAIRN_VERSION }}"``): name of the Docker image that runs Postgresql.
- ``CAIRN_POSTGRESQL_HOST`` (default: ``"cairn-postgresql"``): Host address of the Postgresql database.
- ``CAIRN_POSTGRESQL_PORT`` (default: ``5432``): Postgresql port.
- ``CAIRN_POSTGRESQL_DATABASE`` (default: ``"superset"``): name of the Postgresql database.
- ``CAIRN_POSTGRESQL_USERNAME`` (default: ``"superset"``): Postgresql username.
- ``CAIRN_POSTGRESQL_PASSWORD`` (default: ``"{{ 20|random_string }}"``): Postgresql password.

View File

@ -0,0 +1,3 @@
- [Bugfix] Do not add cairn-postgresql as a dependency when CAIRN_RUN_POSTGRESQL is false. (by @Danyal-Faheem)
- [Bugfix] Add missing CAIRN_POSTGRESQL_HOST and CAIRN_POSTGRESQL_PORT settings to allow usage with external postgresql dbs. (by @Danyal-Faheem)
- [Bugfix] Do not manage cairn-clickhouse permissions CAIRN_RUN_CLICKHOUSE is false. (by @Danyal-Faheem)

View File

@ -23,7 +23,7 @@ cairn-superset-job:
disable: true
depends_on:
{% if RUN_REDIS %}- redis{% endif %}
- cairn-postgresql
{% if CAIRN_RUN_POSTGRESQL %}- cairn-postgresql{% endif %}
cairn-openedx-job:
image: {{ DOCKER_IMAGE_OPENEDX }}
environment:

View File

@ -1,2 +1,2 @@
setowner 1000 /data/cairn-clickhouse
{% if CAIRN_RUN_CLICKHOUSE %}setowner 1000 /data/cairn-clickhouse{% endif %}
{% if CAIRN_RUN_POSTGRESQL %}setowner 70 /data/cairn-postgresql{% endif %}

View File

@ -1,2 +1,2 @@
- ../../data/cairn/clickhouse:/data/cairn-clickhouse
{% if CAIRN_RUN_CLICKHOUSE %}- ../../data/cairn/clickhouse:/data/cairn-clickhouse{% endif %}
{% if CAIRN_RUN_POSTGRESQL %}- ../../data/cairn/postgresql:/data/cairn-postgresql{% endif %}

View File

@ -42,7 +42,7 @@ cairn-superset:
restart: unless-stopped
depends_on:
{% if RUN_REDIS %}- redis{% endif %}
- cairn-postgresql
{% if CAIRN_RUN_POSTGRESQL %}- cairn-postgresql{% endif %}
cairn-superset-worker:
image: {{ CAIRN_SUPERSET_DOCKER_IMAGE }}
volumes:
@ -56,7 +56,7 @@ cairn-superset-worker:
disable: true
depends_on:
{% if RUN_REDIS %}- redis{% endif %}
- cairn-postgresql
{% if CAIRN_RUN_POSTGRESQL %}- cairn-postgresql{% endif %}
cairn-superset-worker-beat:
image: {{ CAIRN_SUPERSET_DOCKER_IMAGE }}
volumes:
@ -70,7 +70,7 @@ cairn-superset-worker-beat:
disable: true
depends_on:
{% if RUN_REDIS %}- redis{% endif %}
- cairn-postgresql
{% if CAIRN_RUN_POSTGRESQL %}- cairn-postgresql{% endif %}
{% if CAIRN_RUN_POSTGRESQL %}
cairn-postgresql:
image: docker.io/postgres:9.6-alpine

View File

@ -34,6 +34,8 @@ config: t.Dict[str, t.Dict[str, t.Any]] = {
"CLICKHOUSE_USERNAME": "openedx",
# Superset/Postgresql
"RUN_POSTGRESQL": True,
"POSTGRESQL_HOST": "cairn-postgresql",
"POSTGRESQL_PORT": "5432",
"POSTGRESQL_DATABASE": "superset",
"POSTGRESQL_USERNAME": "superset",
"SUPERSET_DOCKER_IMAGE": "{{ DOCKER_REGISTRY }}overhangio/cairn-superset:{{ CAIRN_VERSION }}",

View File

@ -11,7 +11,7 @@ from superset.cairn import sso as cairn_sso
# https://superset.apache.org/docs/installation/configuring-superset
SECRET_KEY = "{{ CAIRN_SUPERSET_SECRET_KEY }}"
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://{{ CAIRN_POSTGRESQL_USERNAME }}:{{ CAIRN_POSTGRESQL_PASSWORD }}@cairn-postgresql/{{ CAIRN_POSTGRESQL_DATABASE }}"
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://{{ CAIRN_POSTGRESQL_USERNAME }}:{{ CAIRN_POSTGRESQL_PASSWORD }}@{{ CAIRN_POSTGRESQL_HOST }}:{{ CAIRN_POSTGRESQL_PORT }}/{{ CAIRN_POSTGRESQL_DATABASE }}"
# Caddy is running behind a proxy: Superset needs to handle x-forwarded-* headers
# https://flask.palletsprojects.com/en/latest/deploying/proxy_fix/