Use Ecto compatible DATABASE_URL

ex-png
Marcin Kulik 7 years ago
parent ce5f5ae778
commit 1e130fb159

@ -12,7 +12,7 @@ BASE_URL=http://localhost:3000
SECRET_KEY_BASE= SECRET_KEY_BASE=
## PostgreSQL connection URL. ## PostgreSQL connection URL.
## Default: postgresql://postgres/postgres?user=postgres ## Default: postgresql://postgres@postgres/postgres
# DATABASE_URL= # DATABASE_URL=
## Redis connection URL. ## Redis connection URL.

@ -108,7 +108,7 @@ RUN lein uberjar
COPY . /app COPY . /app
ENV DATABASE_URL "postgresql://postgres/postgres?user=postgres" ENV DATABASE_URL "postgresql://postgres@postgres/postgres"
ENV REDIS_URL "redis://redis:6379" ENV REDIS_URL "redis://redis:6379"
# compile terminal.c # compile terminal.c

@ -50,9 +50,12 @@
(defn- fix-uri [uri] (defn- fix-uri [uri]
(when uri (when uri
(if (str/starts-with? uri "jdbc:") (let [[_ user _ pass] (re-find #"://([^:@]+)(:([^@]+))?@" uri)]
uri (cond-> uri
(str "jdbc:" uri)))) (not (str/starts-with? uri "jdbc:")) (->> (str "jdbc:"))
(str/includes? uri "@") (str/replace #"://[^@]+@" "://")
user (str "?user=" user)
pass (str "&password=" pass)))))
(defn hikaricp [opts] (defn hikaricp [opts]
(let [opts (update opts :uri fix-uri)] (let [opts (update opts :uri fix-uri)]

Loading…
Cancel
Save