···1919if System.get_env("PHX_SERVER") do
2020 config :sower, SowerWeb.Endpoint, server: true
2121end
2222-2323-config :sower, oidc_base_url: System.get_env("SOWER_AUTH_OIDC_BASE_URL")
2424-2525-if config_env() == :prod do
2626- host = System.get_env("SOWER_HOSTNAME") || raise "missing $SOWER_HOSTNAME"
2727- scheme = System.get_env("SOWER_PUBLIC_SCHEME", "https")
2828- public_port = String.to_integer(System.get_env("SOWER_PUBLIC_PORT", "443"))
2929-3030- config :sower,
3131- bootstrap_token: Sower.Application.credential!("SOWER_BOOTSTRAP_TOKEN_FILE"),
3232- oidc_base_url:
3333- System.get_env("SOWER_AUTH_OIDC_BASE_URL") || raise("missing $SOWER_AUTH_OIDC_BASE_URL"),
3434- oidc_client_id: Sower.Application.credential!("SOWER_AUTH_OIDC_CLIENT_ID_FILE"),
3535- oidc_client_secret: Sower.Application.credential!("SOWER_AUTH_OIDC_CLIENT_SECRET_FILE"),
3636- oidc_redirect_uri:
3737- System.get_env("SOWER_AUTH_OIDC_REDIRECT_URI", ~s"#{scheme}://#{host}:#{public_port}/auth")
3838-3939- if System.get_env() |> Map.has_key?("SOWER_DATABASE_SOCKET") do
4040- config :sower, Sower.Repo,
4141- socket: System.get_env("SOWER_DATABASE_SOCKET"),
4242- database: System.get_env("SOWER_DATABASE_NAME", "sower")
4343- else
4444- config :sower, Sower.Repo,
4545- username: System.get_env("SOWER_DATABASE_USER", "sower"),
4646- password: Sower.Application.credential!("SOWER_DATABASE_PASS_FILE"),
4747- hostname: System.get_env("SOWER_DATABASE_HOST", "localhost"),
4848- database: System.get_env("SOWER_DATABASE_NAME", "sower"),
4949- port: System.get_env("SOWER_DATABASE_PORT", "5432") |> String.to_integer()
5050- end
5151-5252- # The secret key base is used to sign/encrypt cookies and other secrets.
5353- # A default value is used in config/dev.exs and config/test.exs but you
5454- # want to use a different value for prod and you most likely don't want
5555- # to check this value into version control, so we use an environment
5656- # variable instead.
5757- secret_key_base = Sower.Application.credential!("SECRET_KEY_BASE_FILE")
5858-5959- port = String.to_integer(System.get_env("SOWER_LISTEN_PORT", "4000"))
6060-6161- {:ok, listen_ip} =
6262- System.get_env("SOWER_LISTEN_ADDRESS", "127.0.0.1")
6363- |> to_charlist()
6464- |> :inet.parse_address()
6565-6666- config :sower, SowerWeb.Endpoint,
6767- url: [host: host, port: public_port, scheme: scheme],
6868- http: [ip: listen_ip, port: port],
6969- secret_key_base: secret_key_base
7070-7171- # ## SSL Support
7272- #
7373- # To get SSL working, you will need to add the `https` key
7474- # to your endpoint configuration:
7575- #
7676- # config :sower, SowerWeb.Endpoint,
7777- # https: [
7878- # ...,
7979- # port: 443,
8080- # cipher_suite: :strong,
8181- # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
8282- # certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
8383- # ]
8484- #
8585- # The `cipher_suite` is set to `:strong` to support only the
8686- # latest and more secure SSL ciphers. This means old browsers
8787- # and clients may not be supported. You can set it to
8888- # `:compatible` for wider support.
8989- #
9090- # `:keyfile` and `:certfile` expect an absolute path to the key
9191- # and cert in disk or a relative path inside priv, for example
9292- # "priv/ssl/server.key". For all supported SSL configuration
9393- # options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
9494- #
9595- # We also recommend setting `force_ssl` in your endpoint, ensuring
9696- # no data is ever sent via http, always redirecting to https:
9797- #
9898- # config :sower, SowerWeb.Endpoint,
9999- # force_ssl: [hsts: true]
100100- #
101101- # Check `Plug.SSL` for all available options in `force_ssl`.
102102-103103- # ## Configuring the mailer
104104- #
105105- # In production you need to configure the mailer to use a different adapter.
106106- # Also, you may need to configure the Swoosh API client of your choice if you
107107- # are not using SMTP. Here is an example of the configuration:
108108- #
109109- # config :sower, Sower.Mailer,
110110- # adapter: Swoosh.Adapters.Mailgun,
111111- # api_key: System.get_env("MAILGUN_API_KEY"),
112112- # domain: System.get_env("MAILGUN_DOMAIN")
113113- #
114114- # For this example you need include a HTTP client required by Swoosh API client.
115115- # Swoosh supports Hackney and Finch out of the box:
116116- #
117117- # config :swoosh, :api_client, Swoosh.ApiClient.Hackney
118118- #
119119- # See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
120120-end