From 29e4f25e1500d22c75d41b45de12df166d178dcd Mon Sep 17 00:00:00 2001 From: Mikael Hugo Date: Sat, 9 May 2026 20:49:09 +0200 Subject: [PATCH] fix: runtime.exs OPS_SECRET_KEY_BASE optional, release.ex handles missing ecto_repos Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- apps/centralcloud_my/lib/centralcloud_my/release.ex | 2 +- config/runtime.exs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/centralcloud_my/lib/centralcloud_my/release.ex b/apps/centralcloud_my/lib/centralcloud_my/release.ex index b97abf1..78464f8 100644 --- a/apps/centralcloud_my/lib/centralcloud_my/release.ex +++ b/apps/centralcloud_my/lib/centralcloud_my/release.ex @@ -13,7 +13,7 @@ defmodule CentralcloudMy.Release do {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version)) end - defp repos, do: Application.fetch_env!(@app, :ecto_repos) + defp repos, do: Application.get_env(@app, :ecto_repos, []) defp load_app do Application.ensure_all_started(:ssl) diff --git a/config/runtime.exs b/config/runtime.exs index 838a1d4..987df92 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -1,12 +1,14 @@ import Config -# Runtime secrets — all required in production, optional in dev (defaults used) +# Runtime secrets — each release only requires its own secret key if config_env() == :prod do config :centralcloud_my, CentralcloudMy.Endpoint, - secret_key_base: System.fetch_env!("MY_SECRET_KEY_BASE") + secret_key_base: System.get_env("MY_SECRET_KEY_BASE") || System.fetch_env!("MY_SECRET_KEY_BASE") - config :centralcloud_ops, CentralcloudOps.Endpoint, - secret_key_base: System.fetch_env!("OPS_SECRET_KEY_BASE") + # OPS_SECRET_KEY_BASE only required when running the centralcloud_ops release + if ops_key = System.get_env("OPS_SECRET_KEY_BASE") do + config :centralcloud_ops, CentralcloudOps.Endpoint, secret_key_base: ops_key + end end config :centralcloud_core, :hostbill,