This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-20
Channels
- # aleph (12)
- # announcements (7)
- # aws (6)
- # babashka (36)
- # beginners (161)
- # boot (1)
- # calva (6)
- # cider (21)
- # clj-kondo (13)
- # cljs-dev (28)
- # cljsrn (1)
- # clojars (3)
- # clojure (13)
- # clojure-colombia (1)
- # clojure-europe (10)
- # clojure-spec (12)
- # clojure-uk (47)
- # clojuredesign-podcast (2)
- # clojurescript (67)
- # datascript (8)
- # datomic (21)
- # duct (3)
- # emacs (6)
- # events (1)
- # fulcro (6)
- # graalvm (98)
- # jobs (1)
- # kaocha (18)
- # luminus (1)
- # malli (7)
- # off-topic (56)
- # pathom (5)
- # re-frame (18)
- # reagent (3)
- # reitit (9)
- # remote-jobs (3)
- # rewrite-clj (10)
- # ring (1)
- # shadow-cljs (155)
- # spacemacs (2)
- # sql (5)
- # tools-deps (27)
- # vim (86)
- # xtdb (2)
So, I managed to get coercion working okay with spec-tools
, and can develop the tutorial mentioned above fine. However, I’ve tried packaging the app using Docker and am having problems attempting to run migrations on startup. My understanding is that you just have to include :duct/migrator
into main.clj
but reviewing the logs, this isn’t working….
(ns film-ratings.main
(:gen-class)
(:require [duct.core :as duct]))
(duct/load-hierarchy)
(defn -main [& args]
(let [keys (or (duct/parse-keys args) [:duct/migrator :duct/daemon])
profiles [:duct.profile/prod]]
(-> (duct/resource "film_ratings/config.edn")
(duct/read-config)
(duct/exec-config profiles keys))))
will@Pauls-MacBook-Pro film-ratings % docker-compose up -d && docker-compose logs -f
Creating network "film-ratings_default" with the default driver
Creating film-ratings_postgres_1 ... done
Creating film-ratings_filmapp_1 ... done
Attaching to film-ratings_filmapp_1, film-ratings_postgres_1
postgres_1 | 2019-11-20 20:24:53.348 UTC [1] LOG: starting PostgreSQL 12.0 on x86_64-pc-linux-musl, compiled by gcc (Alpine 8.3.0) 8.3.0, 64-bit
postgres_1 | 2019-11-20 20:24:53.348 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2019-11-20 20:24:53.348 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2019-11-20 20:24:53.353 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2019-11-20 20:24:53.450 UTC [18] LOG: database system was shut down at 2019-11-20 20:23:44 UTC
postgres_1 | 2019-11-20 20:24:53.481 UTC [1] LOG: database system is ready to accept connections
filmapp_1 | 19-11-20 20:25:05 07de9dcec793 REPORT [duct.server.http.jetty:13] - :duct.server.http.jetty/starting-server {:port 3000}
filmapp_1 | 19-11-20 20:29:24 07de9dcec793 INFO [duct.middleware.web:16] - :duct.middleware.web/request {:request-method :get, :uri "/assets/normalize.css/normalize.css", :query-string nil}
filmapp_1 | 19-11-20 20:29:24 07de9dcec793 INFO [duct.middleware.web:16] - :duct.middleware.web/request {:request-method :get, :uri "/list-films", :query-string nil}
filmapp_1 | 19-11-20 20:29:24 07de9dcec793 INFO [duct.middleware.web:16] - :duct.middleware.web/request {:request-method :get, :uri "/css/site.css", :query-string nil}
postgres_1 | 2019-11-20 20:29:25.391 UTC [25] ERROR: relation "film" does not exist at character 15
Did you rebuild the Docker container of the application after you added the :duct/migrator
key to -main
function? You may be running the old container, without the additional key.
By the way, we don't add the key to -main
. We simply run our apps specifying the keys to initialize using something like java -jar "application-uberjar.jar" ":duct/migrator" ":duct/daemon"
(we have some additional JVM options to tune some parameters, but that's the gist of it). That way we don need to change the code and rebuild the uberjar if we want to use different set of keys.