conform
conform copied to clipboard
Troubles getting started
Hi there,
I'm trying to get started for the first time with conform. Having some trouble with what I thought would be the easy part! :)
I have an umbrella app - one of the applications inside houses an ecto
repo. I decided to try to start pulling in conform in that app as it would be easiest to know if something was broken.
I've created shared_repo.schema.exs
and shared_repo.dev.conf
. If I use mix conform.effective
, I see some values I expect:
shared_repo: [
{SharedRepo.Repo,
[
adapter: Ecto.Adapters.Postgres,
database: "myapp_dev",
hostname: "localhost",
loggers: [
{Ecto.LogEntry,
:log,
[]}
],
pool_size: 10
]},
{:ecto_repos,
[SharedRepo.Repo]}
]
However, when I attempt to boot the app, it blows up as it can't find a database
key inside the configuration for the repo. I'm a bit confused and don't know what to do next. The app boots fine just using a standard config.exs
and config.dev.exs
.
Any help you could provide would be appreciated!
Actually, it's funny, I'm running into a similar problem. Here is the additional check I performed.
- If you are making a release, verify that in the rel/config.exs you have added the
plugin(Conform.ReleasePlugin)
It's funny as well, if I leave my prod.ex file the way it was before using conform so with a line like
config :union, Union.Repo,
adapter: Ecto.Adapters.Postgres,
url: System.get_env("DATABASE_URL"),
Then I find that when I deploy my release the "DATABASE_URL" gets read from the system just when I start the app with the bin script start. So that if I have that env var set when I start it works, if I don't have it, it doesn't work. I always heard that the system.get_env gets read at compile time, it is not true in my case.
If I remove the url line from my prod.ex entirely, then on start I have a database_url not find.
I verified on both cases that the sys.config file gets generated properly with all the values I want.
Did I forget anything, what am I doing wrong?
Ok After some more research on this
looking into my release directory, there is a sys.config file that has the missing env variables
/test/union/releases/0.0.23+7cce925-staging/sys.config
But when I start my app it says that the following config file was generated
/test/union/var/sys.config
and this one is correct.
How do I tell the start script to use that sys.config file instead of the other ?
@happysalada Did you manage to figure anything out on this? I'm still stuck...
@brandonparsons so in the distillery library it talks about several environment variables that you can configure (stuff like RELEASE_CONFIG_DIR, find some more here). I tried changing some of them but couldn't get it to work. Maybe you'll be luckier.
What I ended up doing was using the REPLACE_OS_VARS=true trick. You set that env variable and then in your config file you replace System.get_env by "${your_env_variable}". That worked for me.
I have been using distillery, and specifically tried using Conform to get away from that stuff. Hopefully @bitwalker can chime in at some point.
On Sun, Jun 24, 2018 at 5:19 PM Raphael Megzari [email protected] wrote:
@brandonparsons https://github.com/brandonparsons so in the distillery library it talks about several environment variables that you can configure (stuff like RELEASE_CONFIG_DIR https://hexdocs.pm/distillery/runtime-configuration.html#content, find some more here https://github.com/bitwalker/distillery/blob/master/docs/shell_scripts.md). I tried changing some of them but couldn't get it to work. Maybe you'll be luckier.
What I ended up doing was using the REPLACE_OS_VARS=true trick. You set that env variable and then in your config file you replace System.get_env by "${your_env_variable}". That worked for me.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/bitwalker/conform/issues/155#issuecomment-399796895, or mute the thread https://github.com/notifications/unsubscribe-auth/ABN86pyngNPZkZbHqShcF83llmIPI69rks5uAB6XgaJpZM4Uqn0n .
Hello. Facing a similar problem.
I got everything "working" from the conform
side, in the sense that I was able to produce a sys.config
file for my dev environment which is loaded using: iex --erl "-config $PWD/sys.config" -S mix phx.server
(I know it's correctly loaded because if I enter gibberish, the app doesn't start).
But then everything in there gets ignored.
Is there any way to use sys.config
in dev mode? It's quite important both for practicing and to allow devs to have their own config (for example: change port)