docker-zulip icon indicating copy to clipboard operation
docker-zulip copied to clipboard

Custom setting.py not being picked up

Open Pandry opened this issue 4 years ago • 2 comments

Hello there! I started trying out Zulip using docker and I wanted to integrate a SAML SSO (Keycloak). I tried setting up a custom settings.py file but unfortunately I'm unable to make il work.

AS a workaround, I temporarily edited the file in the host and then copied it in the container and restarted the server (literally docker exec -u zulip zulip_zulip_1 /home/zulip/deployments/current/scripts/restart-server)

Back to the issue... This is the zulip container's log when I try to start up the container with the env variables MANUAL_CONFIGURATION and LINK_SETTINGS_TO_DATA set to true in docker-compose.yml file:

=== Begin Initial Configuration Phase ===
Preparing and linking the uploads folder ...
Prepared and linked the uploads directory.
Executing nginx configuration ...
Nginx configuration succeeded.
Certificates configuration succeeded.
Auto backup enabled.
=== End Initial Configuration Phase ===
=== Begin Bootstrap Phase ===
Waiting for database server to allow connections ...
Executing Zulip first start init ...
First Start Init not needed. Continuing.
Migrating Zulip to new version ...
Traceback (most recent call last):
  File "/home/zulip/deployments/current/manage.py", line 44, in <module>
    log_management_command(" ".join(sys.argv), settings.MANAGEMENT_LOG_PATH)
  File "/home/zulip/deployments/2020-12-01-22-47-56/zulip-py3-venv/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/home/zulip/deployments/2020-12-01-22-47-56/zulip-py3-venv/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/zulip/deployments/2020-12-01-22-47-56/zulip-py3-venv/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/zulip/deployments/2020-12-01-22-47-56/zproject/settings.py", line 19, in <module>
    from .configured_settings import *  # noqa: F401,F403 isort: skip
  File "/home/zulip/deployments/2020-12-01-22-47-56/zproject/configured_settings.py", line 8, in <module>
    from .default_settings import *  # noqa: F401,F403 isort: skip
  File "/home/zulip/deployments/2020-12-01-22-47-56/zproject/default_settings.py", line 13, in <module>
    from .prod_settings import EXTERNAL_HOST, ZULIP_ADMINISTRATOR
ImportError: cannot import name 'EXTERNAL_HOST'
Zulip migration failed with exit code 1. Exiting.

Am I missing something? Unfortunately I had no time to investigate (yet)

Also I would like to highlight that I have a reverse proxy and having DISABLE_HTTPS: "True" (and so a reverse proxy to the HTTP port) results in a AuthFailed: Authentication failed: SAML login failed: ['invalid_response'] (The response was received at https://zulip.example.com:80/complete/saml/ instead of https://zulip.example.com/complete/saml/)

Pandry avatar Dec 28 '20 20:12 Pandry

Plot twist I somehome managed to make my installation working Below are the command I executed (while using nano I'm pretty sure I did not edit the config)

[root@main zulip]# nano settings.py
[root@main zulip]# docker cp settings.py zulip_zulip_1:/etc/zulip/settings.py 
[root@main zulip]# docker exec -u zulip zulip_zulip_1 /home/zulip/deployments/current/scripts/restart-server
[...] # Logs where the server restarts (comes back online nicely as always and SSO works, just like before)
[root@main zulip]# cp settings.py data/zulip/settings/etc-zulip/settings.py                                       
cp: overwrite ‘data/zulip/settings/etc-zulip/settings.py’? y
[root@main zulip]# chmod 444 data/zulip/settings/etc-zulip/settings.py             
[root@main zulip]# docker-compose restart zulip
Restarting zulip_zulip_1 ... done

After this restart the SSO with keycloak was working fine and without any hacky docker cp involved... I think this deserves more attention tho

Pandry avatar Dec 29 '20 23:12 Pandry

Following may or may not help: check if /etc/zulip/settings.py file inside container actually exists and is not empty. Try disabling LINK_SETTINGS_TO_DATA (and/or MANUAL_CONFIGURATION) and check container behavior.

roomcays avatar Dec 09 '23 23:12 roomcays