diff --git a/config/runtime.exs b/config/runtime.exs index d3359c2b..81be8c8e 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -1,22 +1,6 @@ import Config import WandererApp.ConfigHelpers -# config/runtime.exs is executed for all environments, including -# during releases. It is executed after compilation and before the -# system starts, so it is typically used to load production configuration -# and secrets from environment variables or elsewhere. Do not define -# any compile-time configuration in here, as it won't be applied. -# The block below contains prod specific runtime configuration. - -# ## Using releases -# -# If you use `mix release`, you need to explicitly enable the server -# by passing the PHX_SERVER=true when you start it: -# -# PHX_SERVER=true bin/wanderer_app start -# -# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server` -# script that automatically sets the env var above. if System.get_env("PHX_SERVER") do config :wanderer_app, WandererAppWeb.Endpoint, server: true end @@ -178,10 +162,23 @@ if config_env() == :prod do For example: ecto://USER:PASS@HOST/DATABASE """ - maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: [] + maybe_ipv6 = + config_dir + |> get_var_from_path_or_env("ECTO_IPV6", "false") + |> String.to_existing_atom() + |> case do + true -> [:inet6] + _ -> [] + end + + db_ssl_enabled = + config_dir + |> get_var_from_path_or_env("DATABASE_SSL_ENABLED", "false") + |> String.to_existing_atom() config :wanderer_app, WandererApp.Repo, url: database_url, + ssl: db_ssl_enabled, pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), socket_options: maybe_ipv6 diff --git a/mix.exs b/mix.exs index a9f1cc90..58fe97f7 100644 --- a/mix.exs +++ b/mix.exs @@ -56,7 +56,7 @@ defmodule WandererApp.MixProject do {:phoenix, "~> 1.7.12"}, {:phoenix_ecto, "~> 4.6"}, {:ecto_sql, "~> 3.10"}, - {:postgrex, ">= 0.0.0"}, + {:postgrex, "~> 0.19.1"}, {:phoenix_html, "~> 4.0"}, {:phoenix_live_reload, "~> 1.5.3", only: :dev}, {:phoenix_live_view, "~> 0.20.17"}, diff --git a/rel/env.sh.eex b/rel/env.sh.eex index 35d51223..f1f71b10 100755 --- a/rel/env.sh.eex +++ b/rel/env.sh.eex @@ -1,6 +1,5 @@ #!/bin/sh export ERL_AFLAGS="-proto_dist inet6_tcp" -export ECTO_IPV6="true" export RELEASE_DISTRIBUTION="name" export RELEASE_NODE="${FLY_APP_NAME}-${FLY_IMAGE_REF##*-}@${FLY_PRIVATE_IP}"