Skip to content

Commit e3c3491

Browse files
authored
Config cleanup (#1165)
* remove the env files, they aren't used * the python version file is not used * cleanup of the core configs * cleanup of `runtime.exs` * remove git ignore duplication * add a simple docker compose for postgres * add support for DATABASE_URL to dev and test * prod can define the defaults, DATABASE_URL can override them
1 parent ff90726 commit e3c3491

File tree

11 files changed

+256
-270
lines changed

11 files changed

+256
-270
lines changed

.env

Lines changed: 0 additions & 6 deletions
This file was deleted.

.env.dev

Lines changed: 0 additions & 1 deletion
This file was deleted.

.env.test

Lines changed: 0 additions & 4 deletions
This file was deleted.

.gitignore

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,17 @@
11
# App artifacts
22
/_build
3-
/db
4-
/deps
5-
/*.ez
3+
/deps/
4+
/assets/node_modules/
5+
/priv/static/
6+
/tmp/
67

78
# Generated on crash by the VM
89
erl_crash.dump
910

10-
# Files matching config/*.secret.exs pattern contain sensitive
11-
# data and you should not commit them into version control.
12-
#
13-
# Alternatively, you may comment the line below and commit the
14-
# secrets files as long as you replace their contents by environment
15-
# variables.
16-
/config/*.secret.exs
17-
18-
.elixir_ls
19-
.vscode
20-
node_modules
21-
*.iml
11+
# Test artifact
12+
test/fixtures/ssl/device-root-ca.srl
2213

23-
/config/*.secret.exs
24-
/priv/static
25-
.env
2614
.elixir_ls
2715
.vscode
2816

29-
node_modules/
30-
assets/*.log
31-
tmp
32-
33-
gproc_dist*
34-
35-
test/fixtures/ssl/device-root-ca.srl
36-
37-
/remote_host
17+
.env*

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

config/config.exs

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,39 @@ config :phoenix,
1313
]
1414

1515
##
16-
# NervesHub Device
16+
# NervesHub
1717
#
18+
config :nerves_hub,
19+
env: Mix.env(),
20+
namespace: NervesHub,
21+
ecto_repos: [NervesHub.Repo]
1822

19-
# Configures the endpoint
23+
##
24+
# NervesHub Device
25+
#
2026
config :nerves_hub, NervesHubWeb.DeviceEndpoint,
2127
adapter: Bandit.PhoenixAdapter,
2228
render_errors: [view: NervesHubWeb.ErrorView, accepts: ~w(html json)],
2329
pubsub_server: NervesHub.PubSub
2430

2531
##
26-
# NervesHub
32+
# NervesHub Web
2733
#
28-
config :nerves_hub,
29-
env: Mix.env(),
30-
namespace: NervesHub,
31-
ecto_repos: [NervesHub.Repo],
32-
from_email: System.get_env("FROM_EMAIL", "[email protected]")
34+
config :nerves_hub, NervesHubWeb.Endpoint,
35+
adapter: Bandit.PhoenixAdapter,
36+
secret_key_base: "ZH9GG2S5CwIMWXBg92wUuoyKFrjgqaAybHLTLuUk1xZO0HeidcJbnMBSTHDcyhSn",
37+
live_view: [
38+
signing_salt: "Kct3W8U7uQ6KAczYjzNbiYS6A8Pbtk3f"
39+
],
40+
render_errors: [view: NervesHubWeb.ErrorView, accepts: ~w(html json)],
41+
pubsub_server: NervesHub.PubSub
42+
43+
##
44+
# Database and Oban
45+
#
46+
config :nerves_hub, NervesHub.Repo,
47+
queue_target: 500,
48+
queue_interval: 5_000
3349

3450
config :nerves_hub, Oban,
3551
repo: NervesHub.ObanRepo,
@@ -45,30 +61,8 @@ config :nerves_hub, Oban,
4561
]}
4662
]
4763

48-
config :nerves_hub, NervesHub.Repo,
49-
queue_target: 500,
50-
queue_interval: 5_000
51-
52-
##
53-
# NervesHubWWW
54-
#
55-
config :nerves_hub,
56-
ecto_repos: [NervesHub.Repo],
57-
# Options are :ssl or :header
58-
websocket_auth_methods: [:ssl]
59-
6064
config :nerves_hub, NervesHubWeb.Gettext, default_locale: "en"
6165

62-
# Configures the endpoint
63-
config :nerves_hub, NervesHubWeb.Endpoint,
64-
adapter: Bandit.PhoenixAdapter,
65-
secret_key_base: "ZH9GG2S5CwIMWXBg92wUuoyKFrjgqaAybHLTLuUk1xZO0HeidcJbnMBSTHDcyhSn",
66-
live_view: [
67-
signing_salt: "Kct3W8U7uQ6KAczYjzNbiYS6A8Pbtk3f"
68-
],
69-
render_errors: [view: NervesHubWeb.ErrorView, accepts: ~w(html json)],
70-
pubsub_server: NervesHub.PubSub
71-
7266
config :swoosh, :api_client, Swoosh.ApiClient.Finch
7367

7468
# Environment specific config

config/dev.exs

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
import Config
22

3-
# Start all of the applications
4-
config :nerves_hub, app: "all"
5-
6-
config :nerves_hub, deploy_env: "dev"
7-
83
ssl_dir =
94
(System.get_env("NERVES_HUB_CA_DIR") || Path.join([__DIR__, "../test/fixtures/ssl/"]))
105
|> Path.expand()
116

127
config :logger, :console, format: "[$level] $message\n"
138
config :phoenix, :stacktrace_depth, 20
149

15-
# Configure your database
16-
config :nerves_hub, NervesHub.Repo,
17-
url: "postgres://localhost/nerves_hub_dev",
18-
show_sensitive_data_on_connection_error: true,
19-
pool_size: 10
20-
21-
config :nerves_hub, NervesHub.ObanRepo,
22-
url: "postgres://localhost/nerves_hub_dev",
23-
show_sensitive_data_on_connection_error: true,
24-
pool_size: 10
10+
##
11+
# NervesHub Web
12+
#
13+
config :nerves_hub, NervesHubWeb.Endpoint,
14+
url: [
15+
host: System.get_env("WEB_HOST", "localhost"),
16+
scheme: System.get_env("WEB_SCHEME", "http"),
17+
port: String.to_integer(System.get_env("WEB_PORT", "4000"))
18+
],
19+
http: [ip: {0, 0, 0, 0}, port: 4000],
20+
debug_errors: true,
21+
code_reloader: true,
22+
check_origin: false,
23+
watchers: [npm: ["run", "watch", cd: Path.expand("../assets", __DIR__)]],
24+
live_reload: [
25+
patterns: [
26+
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
27+
~r{priv/gettext/.*(po)$},
28+
~r{lib/nerves_hub_www_web/views/.*(ex)$},
29+
~r{lib/nerves_hub_www_web/templates/.*(eex|md)$},
30+
~r{lib/nerves_hube_www_web/live/.*(ex)$}
31+
]
32+
]
2533

2634
##
2735
# NervesHub Device
@@ -58,7 +66,22 @@ config :nerves_hub, NervesHubWeb.DeviceEndpoint,
5866
]
5967

6068
##
61-
# NervesHub
69+
# Database and Oban
70+
#
71+
config :nerves_hub, NervesHub.Repo,
72+
url: System.get_env("DATABASE_URL", "postgres://postgres:postgres@localhost/nerves_hub_dev"),
73+
show_sensitive_data_on_connection_error: true,
74+
pool_size: 10,
75+
ssl: false
76+
77+
config :nerves_hub, NervesHub.ObanRepo,
78+
url: System.get_env("DATABASE_URL", "postgres://postgres:postgres@localhost/nerves_hub_dev"),
79+
show_sensitive_data_on_connection_error: true,
80+
pool_size: 10,
81+
ssl: false
82+
83+
##
84+
# Firmware upload
6285
#
6386
config :nerves_hub, firmware_upload: NervesHub.Firmwares.Upload.File
6487

@@ -74,38 +97,11 @@ config :nerves_hub, NervesHub.Uploads.File,
7497
local_path: Path.expand("tmp/uploads"),
7598
public_path: "/uploads"
7699

77-
# config :nerves_hub, NervesHub.Firmwares.Upload.S3, bucket: System.get_env("S3_BUCKET_NAME")
78-
79-
config :nerves_hub, NervesHub.Repo, ssl: false
80-
81-
config :nerves_hub, NervesHub.ObanRepo, ssl: false
82-
100+
##
101+
# Other
102+
#
83103
config :nerves_hub, NervesHub.SwooshMailer, adapter: Swoosh.Adapters.Local
84104

85105
config :nerves_hub, NervesHub.RateLimit, limit: 10
86106

87-
##
88-
# NervesHubWWW
89-
#
90-
config :nerves_hub, NervesHubWeb.Endpoint,
91-
url: [
92-
host: System.get_env("WEB_HOST", "localhost"),
93-
scheme: System.get_env("WEB_SCHEME", "http"),
94-
port: String.to_integer(System.get_env("WEB_PORT", "4000"))
95-
],
96-
http: [ip: {0, 0, 0, 0}, port: 4000],
97-
debug_errors: true,
98-
code_reloader: true,
99-
check_origin: false,
100-
watchers: [npm: ["run", "watch", cd: Path.expand("../assets", __DIR__)]],
101-
live_reload: [
102-
patterns: [
103-
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
104-
~r{priv/gettext/.*(po)$},
105-
~r{lib/nerves_hub_www_web/views/.*(ex)$},
106-
~r{lib/nerves_hub_www_web/templates/.*(eex|md)$},
107-
~r{lib/nerves_hube_www_web/live/.*(ex)$}
108-
]
109-
]
110-
111107
config :sentry, environment_name: :development

config/prod.exs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ config :logger, level: :info, backends: [:console, Sentry.LoggerBackend]
55

66
config :phoenix, logger: false
77

8+
##
9+
# NervesHub Web
10+
#
11+
config :nerves_hub, NervesHubWeb.Endpoint,
12+
server: true,
13+
force_ssl: [rewrite_on: [:x_forwarded_proto]]
14+
815
##
916
# NervesHub Device
1017
#
1118
config :nerves_hub, NervesHubWeb.DeviceEndpoint, server: true
1219

1320
##
14-
# NervesHub
21+
# Database and Oban
1522
#
1623
config :nerves_hub, NervesHub.Repo, pool_size: 20
1724

1825
config :nerves_hub, NervesHub.ObanRepo, pool_size: 10
19-
20-
##
21-
# NervesHubWWW
22-
#
23-
config :nerves_hub, NervesHubWeb.Endpoint,
24-
server: true,
25-
force_ssl: [rewrite_on: [:x_forwarded_proto]]

0 commit comments

Comments
 (0)