-
Notifications
You must be signed in to change notification settings - Fork 4
Fixed elixir config setup #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
benbot
wants to merge
2
commits into
master
Choose a base branch
from
benbot/fixconfig
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,3 +55,4 @@ result | |
| .envrc | ||
| .elixir_ls | ||
| .elixir-tools | ||
| rel | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| import Config | ||
| require Logger | ||
|
|
||
| # config/runtime.exs is executed for all environments, including | ||
| # during releases. It is executed after compilation and before the | ||
| # system starts, so it is typically used to load production configuration | ||
| # and secrets from environment variables or elsewhere. Do not define | ||
| # any compile-time configuration in here, as it won't be applied. | ||
| # The block below contains prod specific runtime configuration. | ||
|
|
||
| # ## Using releases | ||
| # | ||
| # If you use `mix release`, you need to explicitly enable the server | ||
| # by passing the PHX_SERVER=true when you start it: | ||
| # | ||
| # PHX_SERVER=true bin/oru start | ||
| # | ||
| # Alternatively, you can use `mix phx.gen.release` to generate a `bin/server` | ||
| # script that automatically sets the env var above. | ||
| if System.get_env("PHX_SERVER") do | ||
| config :uro, Uro.Endpoint, server: true | ||
| end | ||
|
|
||
| config :uro, :pow_assent, | ||
| user_identities_context: Uro.UserIdentities, | ||
| providers: | ||
| System.get_env() | ||
| |> Map.filter(fn {k, _} -> String.match?(k, ~r/^OAUTH2_.+_STRATEGY/) end) | ||
| |> Enum.map(fn {key, module_name} -> | ||
| key = | ||
| key | ||
| |> String.replace("OAUTH2_", "") | ||
| |> String.replace("_STRATEGY", "") | ||
|
|
||
| { | ||
| key | ||
| |> String.downcase() | ||
| |> String.to_atom(), | ||
| [ | ||
| client_id: | ||
| System.get_env("OAUTH2_#{key}_CLIENT_ID") || | ||
| raise("Missing client id for oauth strat #{key}"), | ||
| client_secret: | ||
| System.get_env("OAUTH2_#{key}_CLIENT_SECRET") || | ||
| raise("Missing client secret for oauth strat #{key}"), | ||
| strategy: Module.concat([module_name]) | ||
| ] | ||
| } | ||
| end) | ||
|
|
||
| config :uro, Uro.Turnstile, | ||
| secret_key: | ||
| System.get_env("TURNSTILE_SECRET_KEY") || | ||
| Logger.warning( | ||
| "Turnstile (a reCaptcha alternative) is disabled because the environment variable TURNSTILE_SECRET_KEY is not set. For more information, see https://developers.cloudflare.com/turnstile/get-started/." | ||
| ) | ||
|
|
||
| redis_url = System.get_env("REDIS_URL", nil) | ||
| config :uro, Redix, url: if(redis_url, do: redis_url, else: "redis://localhost:6379") | ||
|
|
||
| config :uro, :pow_assent, | ||
| user_identities_context: Uro.UserIdentities, | ||
| providers: | ||
| System.get_env() | ||
| |> Map.filter(fn {k, _} -> String.match?(k, ~r/^OAUTH2_.+_STRATEGY/) end) | ||
| |> Enum.map(fn {key, module_name} -> | ||
| key = | ||
| key | ||
| |> String.replace("OAUTH2_", "") | ||
| |> String.replace("_STRATEGY", "") | ||
|
|
||
| { | ||
| key | ||
| |> String.downcase() | ||
| |> String.to_atom(), | ||
| [ | ||
| client_id: | ||
| System.get_env("OAUTH2_#{key}_CLIENT_ID") || | ||
| Logger.error("OAUTH2_#{key}_CLIENT_ID missing"), | ||
| client_secret: | ||
| System.get_env("OAUTH2_#{key}_SECRET") || Logger.error("OAUTH2_#{key}_SECRET missing"), | ||
| strategy: Module.concat([module_name]) | ||
| ] | ||
| } | ||
| end) | ||
|
|
||
| root_origin = URI.new!(System.get_env("ROOT_ORIGIN") || "https://vsekai.local") | ||
|
|
||
| config :uro, | ||
| ecto_repos: [Uro.Repo], | ||
| url: System.get_env("URL") || "https://vsekai.local/api/v1/", | ||
| frontend_url: URI.new!(System.get_env("FRONTEND_URL") || "https://vsekai.local/"), | ||
| root_origin: root_origin | ||
|
|
||
| config :cors_plug, | ||
| origin: [URI.to_string(root_origin)], | ||
| max_age: 86400 | ||
|
|
||
| if config_env() == :prod do | ||
| config :uro, Uro.Mailer, | ||
| adapter: Swoosh.Adapters.Sendgrid, | ||
| api_key: System.get_env("SENDGRID_API_KEY", "") | ||
|
|
||
| database_url = | ||
| System.get_env("DATABASE_URL") || | ||
| raise """ | ||
| environment variable DATABASE_URL is missing. | ||
| For example: ecto://USER:PASS@HOST/DATABASE | ||
| """ | ||
|
|
||
| maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: [] | ||
|
|
||
| config :joken, | ||
| default_signer: | ||
| System.get_env("JOKEN_SIGNER") || raise("Joken Signer (JOKEN_SIGNER) must be set") | ||
|
|
||
| config :uro, Uro.Repo, | ||
| # ssl: true, | ||
| url: database_url, | ||
| pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), | ||
| socket_options: maybe_ipv6 | ||
|
|
||
| # The secret key base is used to sign/encrypt cookies and other secrets. | ||
| # A default value is used in config/dev.exs and config/test.exs but you | ||
| # want to use a different value for prod and you most likely don't want | ||
| # to check this value into version control, so we use an environment | ||
| # variable instead. | ||
| secret_key_base = | ||
| System.get_env("PHOENIX_KEY_BASE") || | ||
| raise """ | ||
| environment variable SECRET_KEY_BASE is missing. | ||
| You can generate one by calling: mix phx.gen.secret | ||
| """ | ||
|
|
||
| host = System.get_env("PHX_HOST") || "vsekai.local" | ||
| port = String.to_integer(System.get_env("PORT") || "4000") | ||
|
|
||
| config :uro, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY") | ||
|
|
||
| config :uro, Uro.Endpoint, | ||
| url: [host: host, port: 443, scheme: "https"], | ||
| http: [ | ||
| # Enable IPv6 and bind on all interfaces. | ||
| # Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access. | ||
| # See the documentation on https://hexdocs.pm/bandit/Bandit.html#t:options/0 | ||
| # for details about using IPv6 vs IPv4 and loopback vs public addresses. | ||
| ip: {0, 0, 0, 0, 0, 0, 0, 0}, | ||
| port: port | ||
| ], | ||
| secret_key_base: secret_key_base | ||
|
|
||
| # ## SSL Support | ||
| # | ||
| # To get SSL working, you will need to add the `https` key | ||
| # to your endpoint configuration: | ||
| # | ||
| # config :oru, OruWeb.Endpoint, | ||
| # https: [ | ||
| # ..., | ||
| # port: 443, | ||
| # cipher_suite: :strong, | ||
| # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), | ||
| # certfile: System.get_env("SOME_APP_SSL_CERT_PATH") | ||
| # ] | ||
| # | ||
| # The `cipher_suite` is set to `:strong` to support only the | ||
| # latest and more secure SSL ciphers. This means old browsers | ||
| # and clients may not be supported. You can set it to | ||
| # `:compatible` for wider support. | ||
| # | ||
| # `:keyfile` and `:certfile` expect an absolute path to the key | ||
| # and cert in disk or a relative path inside priv, for example | ||
| # "priv/ssl/server.key". For all supported SSL configuration | ||
| # options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1 | ||
| # | ||
| # We also recommend setting `force_ssl` in your config/prod.exs, | ||
| # ensuring no data is ever sent via http, always redirecting to https: | ||
| # | ||
| # config :oru, OruWeb.Endpoint, | ||
| # force_ssl: [hsts: true] | ||
| # | ||
| # Check `Plug.SSL` for all available options in `force_ssl`. | ||
|
|
||
| # ## Configuring the mailer | ||
| # | ||
| # In production you need to configure the mailer to use a different adapter. | ||
| # Also, you may need to configure the Swoosh API client of your choice if you | ||
| # are not using SMTP. Here is an example of the configuration: | ||
| # | ||
| # config :oru, Oru.Mailer, | ||
| # adapter: Swoosh.Adapters.Mailgun, | ||
| # api_key: System.get_env("MAILGUN_API_KEY"), | ||
| # domain: System.get_env("MAILGUN_DOMAIN") | ||
| # | ||
| # For this example you need include a HTTP client required by Swoosh API client. | ||
| # Swoosh supports Hackney and Finch out of the box: | ||
| # | ||
| # config :swoosh, :api_client, Swoosh.ApiClient.Hackney | ||
| # | ||
| # See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details. | ||
| end | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part raises an error at
mix uro.apigenstep. We might need some defaults to run the command at build phase