|
| 1 | +import Config |
| 2 | + |
| 3 | +# config/runtime.exs is executed for all environments, including |
| 4 | +# during releases. It is executed after compilation and before the |
| 5 | +# system starts, so it is typically used to load production configuration |
| 6 | +# and secrets from environment variables or elsewhere. Do not define |
| 7 | +# any compile-time configuration in here, as it won't be applied. |
| 8 | +# The block below contains prod specific runtime configuration. |
| 9 | + |
| 10 | +# ## Using releases |
| 11 | +# |
| 12 | +# If you use `mix release`, you need to explicitly enable the server |
| 13 | +# by passing the PHX_SERVER=true when you start it: |
| 14 | +# |
| 15 | +# PHX_SERVER=true bin/grading_server start |
| 16 | +# |
| 17 | +# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server` |
| 18 | +# script that automatically sets the env var above. |
| 19 | +if System.get_env("PHX_SERVER") do |
| 20 | + config :grading_server, GradingServerWeb.Endpoint, server: true |
| 21 | +end |
| 22 | + |
| 23 | +if config_env() == :prod do |
| 24 | + # The secret key base is used to sign/encrypt cookies and other secrets. |
| 25 | + # A default value is used in config/dev.exs and config/test.exs but you |
| 26 | + # want to use a different value for prod and you most likely don't want |
| 27 | + # to check this value into version control, so we use an environment |
| 28 | + # variable instead. |
| 29 | + secret_key_base = |
| 30 | + System.get_env("SECRET_KEY_BASE") || |
| 31 | + raise """ |
| 32 | + environment variable SECRET_KEY_BASE is missing. |
| 33 | + You can generate one by calling: mix phx.gen.secret |
| 34 | + """ |
| 35 | + |
| 36 | + host = System.get_env("PHX_HOST") || "example.com" |
| 37 | + port = String.to_integer(System.get_env("PORT") || "4000") |
| 38 | + |
| 39 | + config :grading_server, GradingServerWeb.Endpoint, |
| 40 | + url: [host: host, port: 443, scheme: "https"], |
| 41 | + http: [ |
| 42 | + # Enable IPv6 and bind on all interfaces. |
| 43 | + # Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access. |
| 44 | + # See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html |
| 45 | + # for details about using IPv6 vs IPv4 and loopback vs public addresses. |
| 46 | + ip: {0, 0, 0, 0, 0, 0, 0, 0}, |
| 47 | + port: port |
| 48 | + ], |
| 49 | + secret_key_base: secret_key_base |
| 50 | +end |
0 commit comments