I am trying to set up a staging environment and running into problems when I compile using anything other than prod
for my mix env. I’ve tried setting up a custom env called stag
with a stag.exs
file and all that but it appears to break. I’m pretty sure its because of this line I see in mix.exs
:
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
The problem is that i see this line in all my deps folders as well. Does this mean that I should be using a Mix.env
of prod
even for my staging environments?
Phoenix is a web framework built with the Elixir programming language. Elixir, built on the Erlang VM, is used for building low-latency, fault-tolerant, distributed systems, which are increasingly necessary qualities of modern web applications.
A staging environment (stage) is a nearly exact replica of a production environment for software testing. Staging environments are made to test codes, builds, and updates to ensure quality under a production-like environment before application deployment.
Extreme performanceIn one benchmark test, Elixir with Phoenix framework performed up to 13 times better than Ruby on Rails, and upwards of 50% more performance compared to Node. js and Express. The default performance of Phoenix/Elixir is quite impressive.
I don't think I phrased the question correctly. I am creating a release binary and having trouble deploying it in a staging context when I set the MIX_ENV
to anything other than prod
. I was trying to create a custom environment called stag
for staging with its own stag.exs
config file but that was not working as expected. I think I have found the answer I was looking for:
I've discovered via some Elixir IRC channels that :prod
is in fact a build mode and should be used for any cases where one intends to deploy. So in other words, my staging deployment should be set to MIX_ENV=prod
and then either use environment variables for dynamic configuration settings in the prod.exs
file or, as I have done in this case, dynamically load a deployment specific configuration in prod.exs
like so:
deployment_config=System.get_env("DEPLOYMENT_CONFIG")
import_config "./deployment_config/#{deployment_config}.exs"
This approach solved my problem and I am now happily able to run different deployments with their own custom configurations in a release context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With