fix: guard secret_key_base config by RELEASE_NAME
Each release only requires its own secret key: - centralcloud_my needs MY_SECRET_KEY_BASE - centralcloud_staff needs OPS_SECRET_KEY_BASE RELEASE_NAME is set automatically by Elixir release scripts at startup. Fixes startup crash when staff release ran without MY_SECRET_KEY_BASE. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
a4ca979cc2
commit
1758b2465e
1 changed files with 11 additions and 5 deletions
|
|
@ -2,12 +2,18 @@ import Config
|
|||
|
||||
# Runtime secrets — each release only requires its own secret key
|
||||
if config_env() == :prod do
|
||||
config :centralcloud_my, CentralcloudMy.Endpoint,
|
||||
secret_key_base: System.get_env("MY_SECRET_KEY_BASE") || System.fetch_env!("MY_SECRET_KEY_BASE")
|
||||
# RELEASE_NAME is set by the Elixir release scripts at startup.
|
||||
# Each release only requires its own secret key.
|
||||
release = System.get_env("RELEASE_NAME", "")
|
||||
|
||||
# STAFF_SECRET_KEY_BASE only required when running the centralcloud_staff release
|
||||
if staff_key = System.get_env("OPS_SECRET_KEY_BASE") do
|
||||
config :centralcloud_staff, CentralcloudStaff.Endpoint, secret_key_base: staff_key
|
||||
if release != "centralcloud_staff" do
|
||||
config :centralcloud_my, CentralcloudMy.Endpoint,
|
||||
secret_key_base: System.fetch_env!("MY_SECRET_KEY_BASE")
|
||||
end
|
||||
|
||||
if release != "centralcloud_my" do
|
||||
config :centralcloud_staff, CentralcloudStaff.Endpoint,
|
||||
secret_key_base: System.fetch_env!("OPS_SECRET_KEY_BASE")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue