5
votes

I've instantiated two Heroku apps successfully: my-app-prod and my-app-test. There are specific environment variables I've configured in the Heroku app settings. I am using the standard configuration files in Phoenix: config.exs, test.exs, prod.exs, dev.exs.

After configuring my-app-test in Heroku with the app variable MIX_ENV=test, it is still loading variables from prod.exs.

Are there any additional steps I'm missing so that my app uses test.exs?

I followed all the instructions here: https://hexdocs.pm/phoenix/heroku.html

When I run git push, I can verify it's using prod.exs based on the following output.

remote: Generated my_phoenix_app_name app
remote: -----> Creating .profile.d with env vars
remote: -----> Writing export for multi-buildpack support
remote: -----> Executing post compile: pwd
remote: /tmp/build_f5b9e6e5890fcb58b9689f433c554c6a
remote: -----> Phoenix app detected
remote: 
remote: -----> Loading configuration and environment
remote:        Loading config...
remote:        Detecting assets directory
remote:        * package.json found in custom directory
remote:        Will use phoenix configuration:
remote:        * assets path .
remote:        * mix tasks namespace phoenix
remote:        Will use the following versions:
remote:        * Node 5.3.0
remote:        Will export the following config vars:
remote: CLIENT_ID
remote: DATABASE_URL
remote: POOL_SIZE
remote: SECRET_KEY_BASE
remote: SHOPIFY_SECRET
remote:        * MIX_ENV=prod
2
It sounds like it is storing the variables at compile time. Are you running the app with mix phoenix.server or using a distillery release?Mike Buhot
Updated post, thanks.sheldonkreger

2 Answers

2
votes

Buildpack for Elixir is setting MIX_ENV to prod by default, so you don't actually need this setting in your Procfile. You can change it simply to:

web: mix phoenix.server

On my-app-prod you don't have to do anything. On my-app-test just set MIX_ENV to test. You can use command line

heroku config:set MIX_ENV=test --app my-app-test

If it does not work, try to redeploy your apps to Heroku.

0
votes

In your Procfile where it says:

web: MIX_ENV=prod mix phoenix.server

you should be able to change it to:

web: mix phoenix.server

since you are already setting MIX_ENV in the app's settings config vars you should be able to just leave that MIX_ENV part off.