Skip to content

Commit

Permalink
Move configuration to runtime.exs
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti committed Jan 17, 2024
1 parent a7e9eea commit 2518584
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
15 changes: 0 additions & 15 deletions apps/transport/lib/transport_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,4 @@ defmodule TransportWeb.Endpoint do
plug(Plug.Session, @session_options)

plug(TransportWeb.Plugs.Router)

@doc """
Callback invoked for dynamically configuring the endpoint.
It receives the endpoint configuration and checks if
configuration should be loaded from the system environment.
"""
def init(_key, config) do
if config[:load_from_system_env] do
port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
{:ok, Keyword.put(config, :http, [:inet6, port: port])}
else
{:ok, config}
end
end
end
10 changes: 0 additions & 10 deletions config/prod.exs
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import Config

config :transport, TransportWeb.Endpoint,
http: [port: System.get_env("PORT"), compress: true],
url: [scheme: "https", host: System.get_env("DOMAIN_NAME", "transport.data.gouv.fr"), port: 443],
cache_static_manifest: "priv/static/cache_manifest.json",
secret_key_base: System.get_env("SECRET_KEY_BASE"),
force_ssl: [rewrite_on: [:x_forwarded_proto]],
live_view: [
signing_salt: System.get_env("SECRET_KEY_BASE")
]

config :transport,
# The key used by Cloak. See `Transport.Vault`.
# This value should be base64 encrypted
Expand Down
10 changes: 10 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ if config_env() == :prod do
# under "Queue config". For most users, configuring :timeout is enough, as it now includes both queue and query time
timeout: 15_000

config :transport, TransportWeb.Endpoint,
http: [port: System.get_env("PORT"), compress: true],
url: [scheme: "https", host: System.get_env("DOMAIN_NAME"), port: 443],
cache_static_manifest: "priv/static/cache_manifest.json",
secret_key_base: System.get_env("SECRET_KEY_BASE"),
force_ssl: [rewrite_on: [:x_forwarded_proto]],
live_view: [
signing_salt: System.get_env("SECRET_KEY_BASE")
]

if app_env == :production do
# data.gouv.fr IDs for national databases created automatically and
# published by us on data.gouv.fr.
Expand Down

0 comments on commit 2518584

Please sign in to comment.