From 0097ac8672f790ab46f37f0ca4ebfdf1c2a95c7c Mon Sep 17 00:00:00 2001 From: michaeljguarino Date: Sat, 22 Jun 2024 20:05:05 -0400 Subject: [PATCH] Allow db to be configured by url (#1314) --- plural/helm/plural/values.yaml | 1 + rel/config/config.exs | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/plural/helm/plural/values.yaml b/plural/helm/plural/values.yaml index 0f232d53d..b8ea2b7b6 100644 --- a/plural/helm/plural/values.yaml +++ b/plural/helm/plural/values.yaml @@ -325,6 +325,7 @@ admin: enabled: false postgres: + create: true plural: resources: {} size: 50Gi diff --git a/rel/config/config.exs b/rel/config/config.exs index b371400d7..5b65875cd 100644 --- a/rel/config/config.exs +++ b/rel/config/config.exs @@ -23,13 +23,22 @@ config :core, Core.Guardian, issuer: "plural", secret_key: get_env("JWT_SECRET") -config :core, Core.Repo, - database: "plural", - username: "plural", - password: get_env("POSTGRES_PASSWORD"), - hostname: get_env("DBHOST") || "plural-postgresql", - ssl: String.to_existing_atom(get_env("DBSSL") || "false"), - pool_size: 5 + + +if get_env("POSTGRES_URL") do + config :core, Core.Repo, + url: get_env("POSTGRES_URL"), + ssl: String.to_existing_atom(get_env("DBSSL") || "true"), + pool_size: 5 +else + config :core, Core.Repo, + database: "plural", + username: "plural", + password: get_env("POSTGRES_PASSWORD"), + hostname: get_env("DBHOST") || "plural-postgresql", + ssl: String.to_existing_atom(get_env("DBSSL") || "false"), + pool_size: 5 +end config :cloudflare, auth_token: get_env("CLOUDFLARE_AUTH_TOKEN")