From 17bf42c8958a30eee4fc4307f3aff404a0f0cbde Mon Sep 17 00:00:00 2001 From: Sajeyks Date: Wed, 30 Sep 2026 15:33:02 +0300 Subject: [PATCH] Read the secret key from the persisted key file when unset docker compose exec skips the entrypoint, so commands run that way had no DJANGO_SECRET_KEY. Fall back to the file the entrypoint writes. --- dynamicweb/settings/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 00a77d8b..33213e73 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -79,6 +79,13 @@ EMAIL_PORT = int_env("EMAIL_PORT", 25) EMAIL_USE_TLS = bool_env("EMAIL_USE_TLS") SECRET_KEY = env('DJANGO_SECRET_KEY') +if not SECRET_KEY: + # the docker entrypoint persists a generated key here; this lets + # "docker compose exec" commands, which skip the entrypoint, find it + _key_file = env('SECRET_KEY_FILE', '/data/secret-key') + if os.path.exists(_key_file): + with open(_key_file) as _f: + SECRET_KEY = _f.read().strip() # Application definition