diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 5d52708f..2b271d37 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -8,8 +8,8 @@ services: environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - ports: - - '5432:5432' + # ports: + # - '5432:5432' volumes: - db:/var/lib/postgresql/data diff --git a/.env.example b/.env.example index 74fa6faa..0d8bf486 100644 --- a/.env.example +++ b/.env.example @@ -13,5 +13,5 @@ SMTP_USERNAME= # generate this with: -# 32 |> :crypto.strong_rand_bytes() |> Base.encode64() +# elixir --eval "IO.puts Base.encode64(:crypto.strong_rand_bytes(32))" VAULT_KEY="xxxxx" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4853ce1d..9470527d 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ npm-debug.log /assets/*.log .env + +forks/ \ No newline at end of file diff --git a/README.md b/README.md index e8658ef1..aa904ca5 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,12 @@ To start your Phoenix server: * Install dependencies with `mix deps.get` * rename `.env.example` to `.env` and add your variable configurations * Create and migrate your database with `mix ecto.setup` - * Create some fake accounts `mix fake_accounts` * Compile assets `cd assets && yarn install & cd ..` + * Optionally create some fake accounts `mix fake_accounts` * Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server` Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. -# Setup: + ### Generate fake accounts diff --git a/config/dev.exs b/config/dev.exs index d145cb04..b60f218f 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -3,7 +3,7 @@ import Config # Configure your database config :rauversion, Rauversion.Repo, username: "postgres", - password: "postgres", + password: System.get_env("POSTGRES_PASSWORD", "postgres"), database: "rauversion_phx_dev", hostname: System.get_env("DB_HOST", "localhost"), show_sensitive_data_on_connection_error: true, diff --git a/config/runtime.exs b/config/runtime.exs index 677615fb..b59f7e53 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -33,13 +33,19 @@ config :active_storage, :services, root: "tmp/storage" ] -config :rauversion, Rauversion.Vault, - ciphers: [ - default: { - Cloak.Ciphers.AES.GCM, - tag: "AES.GCM.V1", key: Base.decode64!(System.get_env("VAULT_KEY")) - } - ] +key = System.get_env("VAULT_KEY") +with {:ok, key} <- Base.decode64(key) do + config :rauversion, Rauversion.Vault, + ciphers: [ + default: { + Cloak.Ciphers.AES.GCM, + tag: "AES.GCM.V1", key: key + } + ] +else _ -> + raise "Invalid key #{key} - please set env variable VAULT_KEY. You can generate one using: `elixir --eval 'IO.puts Base.encode64(:crypto.strong_rand_bytes(32))'`" +end + config :rauversion, google_maps_key: System.get_env("GOOGLE_MAPS_KEY") @@ -158,4 +164,10 @@ if config_env() == :prod do # ], retries: 2, no_mx_lookups: false + +else + + config :rauversion, Rauversion.Repo, + password: System.get_env("POSTGRES_PASSWORD", "postgres") + end