diff --git a/.env.production.sample b/.env.production.sample index d7b5055..4ee2faa 100644 --- a/.env.production.sample +++ b/.env.production.sample @@ -12,7 +12,7 @@ BASE_URL=http://localhost:3000 SECRET_KEY_BASE= ## PostgreSQL connection URL. -## Default: postgresql://postgres/postgres?user=postgres +## Default: postgresql://postgres@postgres/postgres # DATABASE_URL= ## Redis connection URL. diff --git a/Dockerfile b/Dockerfile index 9612b63..b550d04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -108,7 +108,7 @@ RUN lein uberjar COPY . /app -ENV DATABASE_URL "postgresql://postgres/postgres?user=postgres" +ENV DATABASE_URL "postgresql://postgres@postgres/postgres" ENV REDIS_URL "redis://redis:6379" # compile terminal.c diff --git a/src/asciinema/component/db.clj b/src/asciinema/component/db.clj index 044e113..4008023 100644 --- a/src/asciinema/component/db.clj +++ b/src/asciinema/component/db.clj @@ -50,9 +50,12 @@ (defn- fix-uri [uri] (when uri - (if (str/starts-with? uri "jdbc:") - uri - (str "jdbc:" uri)))) + (let [[_ user _ pass] (re-find #"://([^:@]+)(:([^@]+))?@" uri)] + (cond-> 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] (let [opts (update opts :uri fix-uri)]