Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

split database config and provide prod runtime env

+16 -18
+5 -1
config/dev.exs
··· 2 2 3 3 # Configure your database 4 4 config :sower, Sower.Repo, 5 - url: "ecto://postgres:postgres@localhost/sower_dev", 5 + username: "postgres", 6 + password: "postgres", 7 + hostname: "localhost", 8 + database: "sower_dev", 9 + port: 5432, 6 10 show_sensitive_data_on_connection_error: true, 7 11 pool_size: 10 8 12
-3
config/prod.exs
··· 16 16 # Do not print debug messages in production 17 17 config :logger, level: :info 18 18 19 - # we use nix for building prod and it has a sandbox 20 - config :ex_git, ExGit, skip_compilation?: true 21 - 22 19 # Runtime production configuration, including reading 23 20 # of environment variables, is done on config/runtime.exs.
+11 -14
config/runtime.exs
··· 20 20 config :sower, SowerWeb.Endpoint, server: true 21 21 end 22 22 23 - config :sower, 24 - scm_secret: "five", 25 - working_dir: System.get_env("SOWER_WORKDIR", "#{File.cwd() |> elem(1)}/tmp") 26 - 27 23 if config_env() == :prod do 28 - database_url = 29 - System.get_env("SOWER_DATABASE_URL") || 30 - raise """ 31 - environment variable SOWER_DATABASE_URL is missing. 32 - For example: ecto://postgres:postgres@localhost/ecto_simple 33 - """ 24 + db_pass_file = 25 + System.get_env("SOWER_DATABASE_PASS_FILE") || raise "missing $SOWER_DATABASE_PASS_FILE" 34 26 35 - config :sower, Sower.Repo, url: database_url, socket_options: [:inet6] 27 + config :sower, Sower.Repo, 28 + username: System.get_env("SOWER_DATABASE_USER", "postgres"), 29 + password: db_pass_file |> File.read!() |> String.trim(), 30 + hostname: System.get_env("SOWER_DATABASE_HOST", "localhost"), 31 + database: System.get_env("SOWER_DATABASE_NAME", "sower"), 32 + port: System.get_env("SOWER_DATABASE_PORT", "5432") |> String.to_integer() 36 33 37 34 # The secret key base is used to sign/encrypt cookies and other secrets. 38 35 # A default value is used in config/dev.exs and config/test.exs but you ··· 46 43 You can generate one by calling: mix phx.gen.secret 47 44 """ 48 45 49 - host = System.get_env("SOWER_HOSTNAME") || "example.com" 50 - port = String.to_integer(System.get_env("SOWER_LISTEN_PORT") || "4000") 46 + host = System.get_env("SOWER_HOSTNAME") || raise "missing $SOWER_HOSTNAME" 47 + port = String.to_integer(System.get_env("SOWER_LISTEN_PORT", "4000")) 51 48 52 49 {:ok, listen_ip} = 53 - System.get_env("SOWER_LISTEN_ADDRESS", "::1") 50 + System.get_env("SOWER_LISTEN_ADDRESS", "127.0.0.1") 54 51 |> to_charlist() 55 52 |> :inet.parse_address() 56 53