Skip to content

Commit a8880aa

Browse files
committed
fixing docker release
1 parent e8430ac commit a8880aa

File tree

15 files changed

+211
-231
lines changed

15 files changed

+211
-231
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@ result
5555
.envrc
5656
.elixir_ls
5757
.elixir-tools
58+
cockroach
59+
caddy

config/config.exs

Lines changed: 7 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,6 @@
11
import Config
22
require Logger
33

4-
Code.require_file("config/helpers.exs")
5-
Code.ensure_loaded!(Uro.Config.Helpers)
6-
alias Uro.Config.Helpers
7-
8-
compile_phase? = System.get_env("COMPILE_PHASE") != "false"
9-
10-
get_env = fn key, example ->
11-
case compile_phase? do
12-
true ->
13-
example
14-
15-
false ->
16-
System.get_env(key) ||
17-
raise """
18-
Environment variable "#{key}" is required but not set.
19-
"""
20-
end
21-
end
22-
23-
get_optional_env = fn key ->
24-
System.get_env(key)
25-
end
26-
274
config :uro,
285
compile_phase?: System.get_env("COMPILE_PHASE") != "false"
296

@@ -50,28 +27,13 @@ config :tailwind,
5027
cd: Path.expand("../assets", __DIR__)
5128
]
5229

53-
url =
54-
"URL"
55-
|> get_env.("https://vsekai.local/api/v1/")
56-
|> URI.new!()
57-
58-
root_origin =
59-
"ROOT_ORIGIN"
60-
|> get_env.("https://vsekai.local")
61-
|> URI.new!()
62-
6330
config :uro,
6431
ecto_repos: [Uro.Repo],
65-
url: url,
66-
frontend_url:
67-
"FRONTEND_URL"
68-
|> Helpers.get_env("https://vsekai.local/")
69-
|> URI.new!(),
70-
root_origin: root_origin
32+
url: [host: "localhost"]
7133

7234
config :uro, Uro.Repo,
7335
adapter: Ecto.Adapters.Postgres,
74-
url: Helpers.get_env("DATABASE_URL", "postgresql://vsekai:vsekai@database:5432/vsekai"),
36+
url: System.get_env("DATABASE_URL") || "postgresql://vsekai:vsekai@database:5432/vsekai",
7537
username: "postgres",
7638
password: "postgres",
7739
hostname: "localhost",
@@ -81,48 +43,23 @@ config :uro, Uro.Repo,
8143
pool_size: 10,
8244
migration_lock: false
8345

84-
config :uro, Redix, url: Helpers.get_env("REDIS_URL", "redis://redis:6379")
46+
config :uro, Redix, url: System.get_env("REDIS_URL") || "redis://redis:6379"
8547

8648
config :uro, Uro.Endpoint,
8749
adapter: Bandit.PhoenixAdapter,
8850
url: System.get_env("PHX_HOST") || [host: "localhost"],
89-
http: [
90-
port:
91-
"PORT"
92-
|> Helpers.get_env("4000")
93-
|> String.to_integer()
94-
],
95-
secret_key_base:
96-
Helpers.get_env(
97-
"PHOENIX_KEY_BASE",
98-
"bNDe+pg86uL938fQA8QGYCJ4V7fE5RAxoQ8grq9drPpO7mZ0oEMSNapKLiA48smR"
99-
),
51+
secret_key_base: "bNDe+pg86uL938fQA8QGYCJ4V7fE5RAxoQ8grq9drPpO7mZ0oEMSNapKLiA48smR",
10052
pubsub_server: Uro.PubSub,
101-
live_view: [signing_salt: "0dBPUwA2"],
102-
watchers: [
103-
esbuild: {Esbuild, :install_and_run, [:uro, ~w(--sourcemap=inline --watch)]},
104-
tailwind: {Tailwind, :install_and_run, [:uro, ~w(--watch)]}
105-
]
53+
live_view: [signing_salt: "0dBPUwA2"]
10654

107-
config :cors_plug,
108-
origin: [URI.to_string(root_origin)],
109-
max_age: 86400
110-
111-
config :joken, default_signer: Helpers.get_env("JOKEN_SIGNER", "gqawCOER09ZZjaN8W2QM9XT9BeJSZ9qc")
55+
config :joken, default_signer: "gqawCOER09ZZjaN8W2QM9XT9BeJSZ9qc"
11256

11357
config :uro, :stale_shard_cutoff,
11458
amount: 3,
11559
calendar_type: "month"
11660

11761
config :uro, :stale_shard_interval, 30 * 24 * 60 * 60 * 1000
11862

119-
config :uro, Uro.Turnstile,
120-
secret_key:
121-
get_optional_env.("TURNSTILE_SECRET_KEY") ||
122-
Logger.warning(
123-
"Turnstile (a reCaptcha alternative) is disabled because the environment variable TURNSTILE_SECRET_KEY is not set. For more information, see https://developers.cloudflare.com/turnstile/get-started/."
124-
)
125-
12663
config :uro, :pow,
12764
user: Uro.Accounts.User,
12865
users_context: Uro.Accounts,
@@ -133,34 +70,7 @@ config :uro, :pow,
13370
routes_backend: Uro.Pow.Routes,
13471
cache_store_backend: Uro.Pow.RedisCache
13572

136-
config :uro, :pow_assent,
137-
user_identities_context: Uro.UserIdentities,
138-
providers:
139-
(case(compile_phase?) do
140-
true ->
141-
[]
142-
143-
false ->
144-
System.get_env()
145-
|> Map.filter(fn {k, _} -> String.match?(k, ~r/^OAUTH2_.+_STRATEGY/) end)
146-
|> Enum.map(fn {key, module_name} ->
147-
key =
148-
key
149-
|> String.replace("OAUTH2_", "")
150-
|> String.replace("_STRATEGY", "")
151-
152-
{
153-
key
154-
|> String.downcase()
155-
|> String.to_atom(),
156-
[
157-
client_id: get_env.("OAUTH2_#{key}_CLIENT_ID", nil),
158-
client_secret: get_env.("OAUTH2_#{key}_CLIENT_SECRET", nil),
159-
strategy: Module.concat([module_name])
160-
]
161-
}
162-
end)
163-
end)
73+
config :uro, :pow_assent, user_identities_context: Uro.UserIdentities
16474

16575
config :logger, :console,
16676
format: "$time $metadata[$level] $message\n",

config/dev.exs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,22 @@ config :uro, Uro.Repo,
2929
show_sensitive_data_on_connection_error: true,
3030
pool_size: 10,
3131
url: System.get_env("DATABASE_URL"),
32-
username: "postgres",
33-
password: "postgres",
32+
username: "vsekai",
33+
password: "vsekai",
3434
hostname: "localhost",
35+
port: 26257,
3536
database: "uro-dev",
3637
stacktrace: true,
3738
show_sensitive_data_on_connection_error: true,
38-
pool_size: 10
39+
pool_size: 10,
40+
migration_lock: false
3941

4042
redis_url = Helpers.get_env("REDIS_URL", nil)
4143
config :uro, Redix, url: if(redis_url, do: redis_url, else: "redis://localhost:6379")
44+
45+
46+
config :uro, Uro.Endpoint,
47+
watchers: [
48+
esbuild: {Esbuild, :install_and_run, [:uro, ~w(--sourcemap=inline --watch)]},
49+
tailwind: {Tailwind, :install_and_run, [:uro, ~w(--watch)]}
50+
]

config/prod.exs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
11
import Config
22

3-
# Unused (no static files)
4-
# config :uro, Uro.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
5-
6-
config :uro, Uro.Mailer,
7-
adapter: Swoosh.Adapters.Sendgrid,
8-
api_key: System.get_env("SENDGRID_API_KEY", "")
3+
config :uro, Uro.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
94

105
# Do not print debug messages in production.
116
config :logger, level: :info
12-
13-
url =
14-
"URL"
15-
|> get_env.("https://vsekai.local/api/v1/")
16-
|> URI.new!()
17-
18-
root_origin =
19-
"ROOT_ORIGIN"
20-
|> get_env.("https://vsekai.local")
21-
|> URI.new!()
22-
23-
config :uro, Uro.Endpoint,
24-
adapter: Bandit.PhoenixAdapter,
25-
url: Map.take(url, [:scheme, :host, :path]),
26-
http: [
27-
port:
28-
"PORT"
29-
|> Helpers.get_env("4000")
30-
|> String.to_integer()
31-
]

config/runtime.exs

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
import Config
2+
require Logger
3+
4+
# config/runtime.exs is executed for all environments, including
5+
# during releases. It is executed after compilation and before the
6+
# system starts, so it is typically used to load production configuration
7+
# and secrets from environment variables or elsewhere. Do not define
8+
# any compile-time configuration in here, as it won't be applied.
9+
# The block below contains prod specific runtime configuration.
10+
11+
# ## Using releases
12+
#
13+
# If you use `mix release`, you need to explicitly enable the server
14+
# by passing the PHX_SERVER=true when you start it:
15+
#
16+
# PHX_SERVER=true bin/oru start
17+
#
18+
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
19+
# script that automatically sets the env var above.
20+
if System.get_env("PHX_SERVER") do
21+
config :uro, Uro.Endpoint, server: true
22+
end
23+
24+
config :uro, Uro.Turnstile,
25+
secret_key:
26+
System.get_env("TURNSTILE_SECRET_KEY") ||
27+
Logger.warning(
28+
"Turnstile (a reCaptcha alternative) is disabled because the environment variable TURNSTILE_SECRET_KEY is not set. For more information, see https://developers.cloudflare.com/turnstile/get-started/."
29+
)
30+
31+
config :uro, :pow_assent,
32+
user_identities_context: Uro.UserIdentities,
33+
providers:
34+
System.get_env()
35+
|> Map.filter(fn {k, _} -> String.match?(k, ~r/^OAUTH2_.+_STRATEGY/) end)
36+
|> Enum.map(fn {key, module_name} ->
37+
key =
38+
key
39+
|> String.replace("OAUTH2_", "")
40+
|> String.replace("_STRATEGY", "")
41+
42+
{
43+
key
44+
|> String.downcase()
45+
|> String.to_atom(),
46+
[
47+
client_id: System.get_env("OAUTH2_#{key}_CLIENT_ID") || Logger.error("OAUTH2_#{key}_CLIENT_ID missing"),
48+
client_secret: System.get_env("OAUTH2_#{key}_SECRET") || Logger.error("OAUTH2_#{key}_SECRET missing"),
49+
strategy: Module.concat([module_name])
50+
]
51+
}
52+
end)
53+
54+
55+
if config_env() == :prod do
56+
57+
config :uro, Uro.Mailer,
58+
adapter: Swoosh.Adapters.Sendgrid,
59+
api_key: System.get_env("SENDGRID_API_KEY", "")
60+
61+
database_url =
62+
System.get_env("DATABASE_URL") ||
63+
raise """
64+
environment variable DATABASE_URL is missing.
65+
For example: ecto://USER:PASS@HOST/DATABASE
66+
"""
67+
68+
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
69+
config :joken, default_signer: System.get_env("JOKEN_SIGNER") || raise "Joken Signer (JOKEN_SIGNER) must be set"
70+
71+
config :uro, Uro.Repo,
72+
# ssl: true,
73+
url: database_url,
74+
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
75+
socket_options: maybe_ipv6
76+
77+
# The secret key base is used to sign/encrypt cookies and other secrets.
78+
# A default value is used in config/dev.exs and config/test.exs but you
79+
# want to use a different value for prod and you most likely don't want
80+
# to check this value into version control, so we use an environment
81+
# variable instead.
82+
secret_key_base =
83+
System.get_env("SECRET_KEY_BASE") ||
84+
raise """
85+
environment variable SECRET_KEY_BASE is missing.
86+
You can generate one by calling: mix phx.gen.secret
87+
"""
88+
89+
host = System.get_env("PHX_HOST") || "vsekai.local"
90+
port = String.to_integer(System.get_env("PORT") || "4000")
91+
92+
config :uro, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
93+
94+
config :uro, Uro.Endpoint,
95+
url: [host: host, port: 443, scheme: "https"],
96+
http: [
97+
# Enable IPv6 and bind on all interfaces.
98+
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
99+
# See the documentation on https://hexdocs.pm/bandit/Bandit.html#t:options/0
100+
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
101+
ip: {0, 0, 0, 0, 0, 0, 0, 0},
102+
port: port
103+
],
104+
secret_key_base: secret_key_base
105+
106+
# ## SSL Support
107+
#
108+
# To get SSL working, you will need to add the `https` key
109+
# to your endpoint configuration:
110+
#
111+
# config :oru, OruWeb.Endpoint,
112+
# https: [
113+
# ...,
114+
# port: 443,
115+
# cipher_suite: :strong,
116+
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
117+
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
118+
# ]
119+
#
120+
# The `cipher_suite` is set to `:strong` to support only the
121+
# latest and more secure SSL ciphers. This means old browsers
122+
# and clients may not be supported. You can set it to
123+
# `:compatible` for wider support.
124+
#
125+
# `:keyfile` and `:certfile` expect an absolute path to the key
126+
# and cert in disk or a relative path inside priv, for example
127+
# "priv/ssl/server.key". For all supported SSL configuration
128+
# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
129+
#
130+
# We also recommend setting `force_ssl` in your config/prod.exs,
131+
# ensuring no data is ever sent via http, always redirecting to https:
132+
#
133+
# config :oru, OruWeb.Endpoint,
134+
# force_ssl: [hsts: true]
135+
#
136+
# Check `Plug.SSL` for all available options in `force_ssl`.
137+
138+
# ## Configuring the mailer
139+
#
140+
# In production you need to configure the mailer to use a different adapter.
141+
# Also, you may need to configure the Swoosh API client of your choice if you
142+
# are not using SMTP. Here is an example of the configuration:
143+
#
144+
# config :oru, Oru.Mailer,
145+
# adapter: Swoosh.Adapters.Mailgun,
146+
# api_key: System.get_env("MAILGUN_API_KEY"),
147+
# domain: System.get_env("MAILGUN_DOMAIN")
148+
#
149+
# For this example you need include a HTTP client required by Swoosh API client.
150+
# Swoosh supports Hackney and Finch out of the box:
151+
#
152+
# config :swoosh, :api_client, Swoosh.ApiClient.Hackney
153+
#
154+
# See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
155+
end

config/test.exs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import Config
33
config :uro, Uro.Repo,
44
show_sensitive_data_on_connection_error: true,
55
url: System.get_env("TEST_DATABASE_URL"),
6-
username: "postgres",
7-
password: "postgres",
6+
username: "vsekai",
7+
password: "vsekai",
88
hostname: "localhost",
9+
port: 26257,
910
database: "uro-test",
1011
stacktrace: true,
1112
show_sensitive_data_on_connection_error: true,

0 commit comments

Comments
 (0)