fix(docker): Fix DB connection in docker-compose internal network

This commit is contained in:
Dmitry Popov
2024-09-19 17:14:08 +04:00
parent 152ee60576
commit ebd01bebd4
3 changed files with 15 additions and 19 deletions
+14 -17
View File
@@ -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
+1 -1
View File
@@ -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"},
-1
View File
@@ -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}"