axelson

axelson

Scenic Core Team

Just wanted to note that the change you made here didn’t actually make the difference you thought it did. Both of those calls are executed at the same time. Which is usually runtime unless you’re using a module attribute or some other compile time facility.

0
Post #11
zoedsoupe

zoedsoupe OP

Yeah! Now I understand better the compile/runtime thing!

I can create the release as:
MIX_ENV=prod mix release

without any env var such as DB_URL

But when I start the app I need to export or set on one-line!

0
Post #12
zoedsoupe

zoedsoupe OP

However… You have any idea why my tests are breaking with this error:
** (ArgumentError) cookie store expects conn.secret_key_base to be set?

It seems that on test env the app is retrieving th SECRET_KEY_BASE env var, but this one is only set on runtime.exs

executing tests as:
SECRET_KEY_BASE=xxxxxxx mix test

gives me:

Finished in 41.0 seconds
35 tests, 0 failures
0
Post #13
NobbZ

NobbZ

As far as I know, config/test.exs does not set or overwrite the secret_key_base in a default generated application.

So you might have changed some things for a reason or by accident. It does not make (much) sense to read the env during test. If you do not want to hardcode a secret_key_base in config/config.exs (which is still there) you can remove it there and use config/runtime.exs instead to read it from the env, while hardcoding some “well known secret” in config/test.exs.

Or you just don’t touch the value in the test config and use the one from the “main” config as a well known default, that you shouldn’t use in production then though.

1
Post #14
zoedsoupe

zoedsoupe OP

That’s the problem… I didn’t change nothing for tests neither test.exs

grepping for SECRET_KEY_BASE and secret_key_base gaves me this:

conts git:(deploy)$✘!? elixir:(1.11.0)
ﬦ grep -rnw . -e 'secret_key_base' --exclude-dir deps -I -l
./erl_crash.dump
./config/runtime.exs
./config/config.exs
./assets/node_modules/phoenix/lib/phoenix/endpoint.ex
./assets/node_modules/phoenix/lib/phoenix/socket/transport.ex
./assets/node_modules/phoenix/lib/phoenix/token.ex
./assets/node_modules/phoenix/lib/phoenix/endpoint/supervisor.ex
./_build/prod/rel/conts/releases/0.1.0/runtime.exs
./_build/prod/rel/conts/releases/0.1.0/sys.config
./_build/prod/rel/conts/tmp/conts-0.1.0-20201230182825-2b8b.runtime.config

conts git:(deploy)$✘!? elixir:(1.11.0)
ﬦ grep -rnw . -e 'SECRET_KEY_BASE' --exclude-dir deps -I -l
./config/runtime.exs
./_build/prod/rel/conts/releases/0.1.0/runtime.exs
./deploy/deploy.sh
./deploy/Dockerfile

Which I think is totally fine

I’ll try rollback on one branch! I created a new one called deploy for this case! If everything goes wrong, rollback haha

0
Post #15
zoedsoupe

zoedsoupe OP

If you get here from google, I strongly advise you to read the entire topic! You’ll learn a lot!

Yeah! Rolling back to another branch solved the test issues…

So summing up:

env var not matter on creating a release with
MIX_ENV=prod mix release

they only matter on starting the release!

Thank you all so much!

0
Post #16
NobbZ

NobbZ

It is not that easy. Depending on how and where you read them they might also affect the build.

config/runtime.exs is only evaluated during application boot, therefore its solely runtime config.

2
Post #17
— All posts loaded —