This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-26
Channels
- # aleph (5)
- # announcements (16)
- # babashka (36)
- # beginners (161)
- # calva (24)
- # cider (8)
- # circleci (45)
- # clj-kondo (5)
- # cljs-dev (25)
- # cljsrn (5)
- # clojure (116)
- # clojure-europe (10)
- # clojure-nl (18)
- # clojure-uk (14)
- # clojuredesign-podcast (6)
- # clojurescript (50)
- # cursive (12)
- # data-science (8)
- # datomic (8)
- # duct (39)
- # emacs (6)
- # fulcro (21)
- # graalvm (12)
- # kaocha (17)
- # off-topic (184)
- # pathom (1)
- # pedestal (2)
- # re-frame (31)
- # reagent (24)
- # reitit (1)
- # sci (1)
- # shadow-cljs (23)
- # sql (147)
- # tools-deps (8)
- # vrac (3)
- # xtdb (35)
hey everyone, Im trying to to make duct read configuration from env vars (this part is ok!)
but im trying to find a way, in development and in test, to export specific env variables
is dev/resources/dev.edn
the right place to do so? (I intend to commit these default values)
Im aware that I can use default values like
{:port #env ["PORT" Int :or 3000]}
but Id like to avoid default values production
so Ideally the application always reads from env, and when Im developing or run lein test
other env variables are usedYou can override the keys in your dev/test profiles. So in your base profile (which will filter through to prod) you can have {:port #duct/env ["PORT" Int]}
, and in dev/test {:port #duct/env ["DEV_PORT" Int :or 3000]}
.
so I have to duplicate the edn file structure in the test profile?
but change only the :port
field?
I'd recommend creating a sandbox project with lein new duct sandbox
to have a "live" example you can play with
The default config looks like this:
{:duct.profile/base
{:duct.core/project-ns sandbox}
:duct.profile/dev #duct/include "dev"
:duct.profile/local #duct/include "local"
:duct.profile/prod {}
:duct.module/logging {}}
> so I have to duplicate the edn file structure in the test profile? No, integrant is smart enough that you can only override the keys you want to change
So if you have {:some/component {:foo 1, :bar 2}}
in your base profile, and {:some/component {:foo 10}}
in your dev profile, the component will end up getting initialized with {:foo 10, :bar 2}
FYI, this is used by duct for merging configuration: https://github.com/weavejester/meta-merge You can see all the options you have with this
how can I specify other profile? lein with-profile :duct.profile/my-profile run
is not working