siga

Sistema Interativo de GerĂȘncia de Atividades.
Log | Files | Refs | README | LICENSE

runtime.exs (3637B)


      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/users 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 :users, UsersWeb.Endpoint, server: true
     21 end
     22 
     23 config :users, UsersWeb.Endpoint, http: [port: String.to_integer(System.get_env("PORT", "4000"))]
     24 
     25 if auth_url = System.get_env("SIGA_AUTH_URL") do
     26   config :users, :auth_url, auth_url
     27 end
     28 
     29 if config_env() == :prod do
     30   database_path =
     31     System.get_env("DATABASE_PATH") ||
     32       raise """
     33       environment variable DATABASE_PATH is missing.
     34       For example: /etc/users/users.db
     35       """
     36 
     37   config :users, Users.Repo,
     38     database: database_path,
     39     pool_size: String.to_integer(System.get_env("POOL_SIZE") || "5")
     40 
     41   # The secret key base is used to sign/encrypt cookies and other secrets.
     42   # A default value is used in config/dev.exs and config/test.exs but you
     43   # want to use a different value for prod and you most likely don't want
     44   # to check this value into version control, so we use an environment
     45   # variable instead.
     46   secret_key_base =
     47     System.get_env("SECRET_KEY_BASE") ||
     48       raise """
     49       environment variable SECRET_KEY_BASE is missing.
     50       You can generate one by calling: mix phx.gen.secret
     51       """
     52 
     53   host = System.get_env("PHX_HOST") || "example.com"
     54 
     55   config :users, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
     56 
     57   config :users, UsersWeb.Endpoint,
     58     url: [host: host, port: 443, scheme: "https"],
     59     http: [
     60       # Enable IPv6 and bind on all interfaces.
     61       # Set it to  {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
     62       # See the documentation on https://bandit.hexdocs.pm/Bandit.html#t:options/0
     63       # for details about using IPv6 vs IPv4 and loopback vs public addresses.
     64       ip: {0, 0, 0, 0, 0, 0, 0, 0}
     65     ],
     66     secret_key_base: secret_key_base
     67 
     68   # ## SSL Support
     69   #
     70   # To get SSL working, you will need to add the `https` key
     71   # to your endpoint configuration:
     72   #
     73   #     config :users, UsersWeb.Endpoint,
     74   #       https: [
     75   #         ...,
     76   #         port: 443,
     77   #         cipher_suite: :strong,
     78   #         keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
     79   #         certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
     80   #       ]
     81   #
     82   # The `cipher_suite` is set to `:strong` to support only the
     83   # latest and more secure SSL ciphers. This means old browsers
     84   # and clients may not be supported. You can set it to
     85   # `:compatible` for wider support.
     86   #
     87   # `:keyfile` and `:certfile` expect an absolute path to the key
     88   # and cert in disk or a relative path inside priv, for example
     89   # "priv/ssl/server.key". For all supported SSL configuration
     90   # options, see https://plug.hexdocs.pm/Plug.SSL.html#configure/1
     91   #
     92   # We also recommend setting `force_ssl` in your config/prod.exs,
     93   # ensuring no data is ever sent via http, always redirecting to https:
     94   #
     95   #     config :users, UsersWeb.Endpoint,
     96   #       force_ssl: [hsts: true]
     97   #
     98   # Check `Plug.SSL` for all available options in `force_ssl`.
     99 end