Skip to content

Commit 7864119

Browse files
committed
chore: Add runtime config
1 parent 12bf29f commit 7864119

File tree

6 files changed

+93
-54
lines changed

6 files changed

+93
-54
lines changed

.gitignore

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The directory Mix will write compiled artifacts to.
2-
/_build/
3-
/.elixir_ls
2+
/_build/
3+
/.elixir_ls
44
.env
55
# If you run "mix test --cover", coverage assets end up here.
66
/cover/
@@ -29,7 +29,7 @@ npm-debug.log
2929
# The directory NPM downloads your dependencies sources to.
3030
/assets/node_modules/
3131

32-
# Since we are building assets from assets/,
33-
# we ignore priv/static. You may want to comment
34-
# this depending on your deployment strategy.
32+
# Since we are building assets from assets/,
33+
# we ignore priv/static. You may want to comment this depending on your deployment
34+
# strategy.
3535
/priv/static/

config/config.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ config :esbuild,
3636
]
3737

3838
config :tailwind,
39-
version: "3.0.10",
39+
version: "3.0.12",
4040
default: [
4141
args: ~w(
4242
--config=tailwind.config.js

config/prod.exs

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import Config
1010
# which you should run after static files are built and
1111
# before starting your production server.
1212
config :brasil_em_dados, BrasilEmDadosWeb.Endpoint,
13-
url: [host: "brasilemdados.com", port: 80],
1413
cache_static_manifest: "priv/static/cache_manifest.json"
1514

1615
# Do not print debug messages in production
@@ -48,8 +47,4 @@ config :logger, level: :info
4847
# config :brasil_em_dados, BrasilEmDadosWeb.Endpoint,
4948
# force_ssl: [hsts: true]
5049
#
51-
# Check `Plug.SSL` for all available options in `force_ssl`.
52-
53-
# Finally import the config/prod.secret.exs which loads secrets
54-
# and configuration from environment variables.
55-
import_config "prod.secret.exs"
50+
# Check `Plug.SSL` for all available options in `force_ssl`.

config/prod.secret.exs

-41
This file was deleted.

config/runtime.exs

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
# Start the phoenix server if environment is set and running in a release
11+
if System.get_env("PHX_SERVER") && System.get_env("RELEASE_NAME") do
12+
config :brasil_em_dados, BrasilEmDadosWeb.Endpoint, server: true
13+
end
14+
15+
if config_env() == :prod do
16+
database_url =
17+
System.get_env("DATABASE_URL") ||
18+
raise """
19+
environment variable DATABASE_URL is missing.
20+
For example: ecto://USER:PASS@HOST/DATABASE
21+
"""
22+
23+
maybe_ipv6 = if System.get_env("ECTO_IPV6"), do: [:inet6], else: []
24+
25+
config :brasil_em_dados, BrasilEmDados.Repo,
26+
# ssl: true,
27+
url: database_url,
28+
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
29+
socket_options: maybe_ipv6
30+
# show_sensitive_data_on_connection_error: true # The secret key base is used to sign/encrypt cookies and other secrets.
31+
# A default value is used in config/dev.exs and config/test.exs but you
32+
# want to use a different value for prod and you most likely don't want
33+
# to check this value into version control, so we use an environment
34+
# variable instead.
35+
secret_key_base =
36+
System.get_env("SECRET_KEY_BASE") ||
37+
raise """
38+
environment variable SECRET_KEY_BASE is missing.
39+
You can generate one by calling: mix phx.gen.secret
40+
"""
41+
42+
host = System.get_env("PHX_HOST") || "brasilemdados.com"
43+
port = String.to_integer(System.get_env("PORT") || "4000")
44+
45+
config :brasil_em_dados, BrasilEmDadosWeb.Endpoint,
46+
url: [host: host, port: 443],
47+
http: [
48+
# Enable IPv6 and bind on all interfaces.
49+
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
50+
# See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
51+
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
52+
ip: {0, 0, 0, 0, 0, 0, 0, 0},
53+
port: port
54+
],
55+
secret_key_base: secret_key_base,
56+
check_origin: false
57+
58+
# ## Using releases
59+
#
60+
# If you are doing OTP releases, you need to instruct Phoenix
61+
# to start each relevant endpoint:
62+
#
63+
config :brasil_em_dados, BrasilEmDadosWeb.Endpoint, server: true
64+
#
65+
# Then you can assemble a release by calling `mix release`.
66+
# See `mix help release` for more information.
67+
68+
# ## Configuring the mailer
69+
#
70+
# In production you need to configure the mailer to use a different adapter.
71+
# Also, you may need to configure the Swoosh API client of your choice if you
72+
# are not using SMTP. Here is an example of the configuration:
73+
#
74+
# config :brasil_em_dados, BrasilEmDados.Mailer,
75+
# adapter: Swoosh.Adapters.Mailgun,
76+
# api_key: System.get_env("MAILGUN_API_KEY"),
77+
# domain: System.get_env("MAILGUN_DOMAIN")
78+
#
79+
# For this example you need include a HTTP client required by Swoosh API client.
80+
# Swoosh supports Hackney and Finch out of the box:
81+
#
82+
# config :swoosh, :api_client, Swoosh.ApiClient.Hackney
83+
#
84+
# See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
85+
end

mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ defmodule BrasilEmDados.MixProject do
5151
{:plug_cowboy, "~> 2.0"},
5252
{:earmark, "~> 1.4.14"},
5353
{:esbuild, "~> 0.4.0", runtime: Mix.env() == :dev},
54-
{:tailwind, "~> 0.1.5", runtime: Mix.env() == :dev},
54+
{:tailwind, "~> 0.1.5"},
5555
{:scrivener_ecto, "~> 2.7.0"}
5656
]
5757
end

0 commit comments

Comments
 (0)