[英]Setting MIX_ENV in Heroku for Phoenix Framework
我成功地實例化了兩個Heroku應用程序:my-app-prod和my-app-test。 我在Heroku應用程序設置中配置了特定的環境變量。 我在Phoenix使用標准配置文件:config.exs,test.exs,prod.exs,dev.exs。
在Heroku中使用app變量MIX_ENV = test配置my-app-test后,它仍然從prod.exs加載變量。
我還缺少任何額外的步驟,以便我的應用程序使用test.exs嗎?
我按照這里的所有說明操作: https : //hexdocs.pm/phoenix/heroku.html
當我運行git push時,我可以根據以下輸出驗證它是否正在使用prod.exs。
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
Elixir的MIX_ENV
默認將MIX_ENV
設置為prod
,因此您在Procfile中實際上不需要此設置。 您可以將其更改為:
web: mix phoenix.server
在my-app-prod
你不需要做任何事情。 在my-app-test
上設置MIX_ENV
進行test
。 您可以使用命令行
heroku config:set MIX_ENV=test --app my-app-test
如果它不起作用,請嘗試將您的應用重新部署到Heroku。
在您的Procfile
,它說:
web: MIX_ENV=prod mix phoenix.server
你應該能夠把它改成:
web: mix phoenix.server
由於您已經在應用程序的設置配置變量中設置了MIX_ENV
,因此您應該可以將MIX_ENV部分關閉。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.