From 69576aa253e5dff5f6eb512be8dc2e2c13e21b43 Mon Sep 17 00:00:00 2001 From: Uku Taht <uku.taht@gmail.com> Date: Fri, 21 Jan 2022 14:23:09 -0600 Subject: [PATCH] Default to 127.0.0.1 listen_ip on non-docker use-cases --- Dockerfile | 1 + config/runtime.exs | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b6bc4c8..3815c9f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,6 +70,7 @@ RUN chown -R plausibleuser:plausibleuser /app USER plausibleuser WORKDIR /app ENV GEONAMES_SOURCE_FILE=/app/lib/plausible-0.0.1/priv/geonames.csv +ENV LISTEN_IP=0.0.0.0 ENTRYPOINT ["/entrypoint.sh"] EXPOSE 8000 CMD ["run"] diff --git a/config/runtime.exs b/config/runtime.exs index 7ea33f73..46372f0a 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -8,16 +8,18 @@ end config_dir = System.get_env("CONFIG_DIR", "/run/secrets") # Listen IP supports IPv4 and IPv6 addresses. -listen_ip = ( - str = get_var_from_path_or_env(config_dir, "LISTEN_IP") || "0.0.0.0" - case :inet.parse_address(String.to_charlist(str)) do - {:ok, ip_addr} -> - ip_addr - - {:error, reason} -> - raise "Invalid LISTEN_IP '#{str}' error: #{inspect(reason)}" - end -) +listen_ip = + ( + str = get_var_from_path_or_env(config_dir, "LISTEN_IP") || "127.0.0.1" + + case :inet.parse_address(String.to_charlist(str)) do + {:ok, ip_addr} -> + ip_addr + + {:error, reason} -> + raise "Invalid LISTEN_IP '#{str}' error: #{inspect(reason)}" + end + ) # System.get_env does not accept a non string default port = get_var_from_path_or_env(config_dir, "PORT") || 8000 -- GitLab