From 4fd5cdff589fa1905c6022c6a9ddd1bcc63de26f Mon Sep 17 00:00:00 2001
From: Uku Taht <uku.taht@gmail.com>
Date: Tue, 13 Apr 2021 12:36:47 +0300
Subject: [PATCH] Add download step to docker build

---
 Dockerfile         | 3 ++-
 config/runtime.exs | 8 +++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index d764bb12..eba9f485 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -40,7 +40,8 @@ COPY lib ./lib
 
 RUN npm run deploy --prefix ./assets && \
     npm run deploy --prefix ./tracker && \
-    mix phx.digest priv/static
+    mix phx.digest priv/static && \
+    mix download_country_database
 
 WORKDIR /app
 COPY rel rel
diff --git a/config/runtime.exs b/config/runtime.exs
index d7a33355..7c9cc142 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -66,7 +66,13 @@ cron_enabled = String.to_existing_atom(System.get_env("CRON_ENABLED", "false"))
 custom_domain_server_ip = System.get_env("CUSTOM_DOMAIN_SERVER_IP")
 custom_domain_server_user = System.get_env("CUSTOM_DOMAIN_SERVER_USER")
 custom_domain_server_password = System.get_env("CUSTOM_DOMAIN_SERVER_PASSWORD")
-geolite2_country_db = System.get_env("EOLITE2_COUNTRY_DB", "priv/geodb/dbip-country.mmdb")
+
+geolite2_country_db =
+  System.get_env(
+    "GEOLITE2_COUNTRY_DB",
+    Application.app_dir(:plausible) <> "/priv/geodb/dbip-country.mmdb"
+  )
+
 disable_auth = String.to_existing_atom(System.get_env("DISABLE_AUTH", "false"))
 disable_registration = String.to_existing_atom(System.get_env("DISABLE_REGISTRATION", "false"))
 hcaptcha_sitekey = System.get_env("HCAPTCHA_SITEKEY")
-- 
GitLab