Using Fly secrets in Mix configs

Hello,

I’m trying to deploy an app that makes use of several System.get_env calls to fetch things like API keys and OAuth credentials. It all works fine locally and I saved the variables to Fly secrets, but can’t seem to read them via System.get_env in my config.exs when the app attempts to build. I’ve also tried adding my secrets as --build-args and still no luck. I feel like I’m probably missing something obvious here…

Thanks for any help!

You need to put them in config/runtime.exs, so they are read at runtime. You can see examples of this in the runtime.exs that phoenix generated for you, for things like DATABASE_URL. The other configuration files are run at compile time, so your fly env is not present at that time. Throw them in runtime.exs and you’ll be all set :slight_smile:

Oh thank you so much! I knew it had to be something simple!