From a4988e5cd47285c4e42e9430279eb66a554e0b9d Mon Sep 17 00:00:00 2001 From: Drew Bonasera Date: Mon, 27 Apr 2026 02:33:06 -0400 Subject: [PATCH 1/2] Install netcat in the dev container and make the database hostname configurable. - build(devcontainer): Install netcat-traditional package - feat(config): Make database hostname configurable via DB_HOST env var --- .devcontainer/Dockerfile | 1 + config/dev.exs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 59dfcc15..d2fcdeb6 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -15,6 +15,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ vim \ net-tools \ procps \ + netcat-traditional \ # Optionally add any other tools you need, e.g. vim, wget... && curl -sL https://deb.nodesource.com/setup_18.x | bash - \ && apt-get install -y --no-install-recommends nodejs inotify-tools \ diff --git a/config/dev.exs b/config/dev.exs index 7b18a442..9991ddd7 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -4,7 +4,7 @@ import Config config :wanderer_app, WandererApp.Repo, username: "postgres", password: "postgres", - hostname: "localhost", + hostname: System.get_env("DB_HOST", "localhost"), database: "wanderer_dev", stacktrace: true, show_sensitive_data_on_connection_error: true, From ddf34351c96abc1b088636659766caf30c408a52 Mon Sep 17 00:00:00 2001 From: Drew Bonasera Date: Tue, 2 Jun 2026 08:40:10 -0400 Subject: [PATCH 2/2] Move the `DB_HOST` environment variable evaluation from compile-time configuration to runtime configuration for the development and test environments. The compile-time `dev` and `test` configurations now default the database hostname to `localhost`. - fix(config): Set default database hostname to `localhost` in `dev.exs` and `test.exs` - fix(config): Add `DB_HOST` environment variable override for dev and test environments to `runtime.exs` --- config/dev.exs | 2 +- config/runtime.exs | 6 ++++++ config/test.exs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config/dev.exs b/config/dev.exs index 9991ddd7..7b18a442 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -4,7 +4,7 @@ import Config config :wanderer_app, WandererApp.Repo, username: "postgres", password: "postgres", - hostname: System.get_env("DB_HOST", "localhost"), + hostname: "localhost", database: "wanderer_dev", stacktrace: true, show_sensitive_data_on_connection_error: true, diff --git a/config/runtime.exs b/config/runtime.exs index 4f53cd05..adccbf30 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -5,6 +5,12 @@ if System.get_env("PHX_SERVER") do config :wanderer_app, WandererAppWeb.Endpoint, server: true end +if config_env() in [:dev, :test] do + if db_host = System.get_env("DB_HOST") do + config :wanderer_app, WandererApp.Repo, hostname: db_host + end +end + config_dir = System.get_env("CONFIG_DIR", "/run/secrets") app_name = System.get_env("FLY_APP_NAME", "NOT_FLY_APP") diff --git a/config/test.exs b/config/test.exs index 3a9d0b38..728886f4 100644 --- a/config/test.exs +++ b/config/test.exs @@ -12,7 +12,7 @@ config :ash, :disable_async?, true config :wanderer_app, WandererApp.Repo, username: "postgres", password: "postgres", - hostname: System.get_env("DB_HOST", "localhost"), + hostname: "localhost", database: "wanderer_test#{System.get_env("MIX_TEST_PARTITION")}", pool: Ecto.Adapters.SQL.Sandbox, pool_size: 20,