Skip to content

Commit 504004b

Browse files
update config
1 parent dcb8282 commit 504004b

File tree

4 files changed

+68
-6
lines changed

4 files changed

+68
-6
lines changed

config/dcompose.exs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Config
2+
3+
# Note we also include the path to a cache manifest
4+
# containing the digested version of static files. This
5+
# manifest is generated by the `mix assets.deploy` task,
6+
# which you should run after static files are built and
7+
# before starting your production server.
8+
config :fileonchain, FileonchainWeb.Endpoint,
9+
url: [host: System.get_env("PHX_HOST") || "localhost"],
10+
render_errors: [
11+
formats: [html: FileonchainWeb.ErrorHTML, json: FileonchainWeb.ErrorJSON],
12+
layout: false
13+
],
14+
cache_static_manifest: "priv/static/cache_manifest.json",
15+
debug_errors: true
16+
17+
# Configures Swoosh API Client
18+
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Fileonchain.Finch
19+
20+
# Disable Swoosh Local Memory Storage
21+
config :swoosh, local: false
22+
23+
# Do not print debug messages in production
24+
config :logger, level: :info
25+
26+
# Configure Swoosh for email sending
27+
config :fileonchain, Fileonchain.Mailer,
28+
adapter: Swoosh.Adapters.SMTP,
29+
relay: System.get_env("SMTP_HOST") || "smtp",
30+
port: String.to_integer(System.get_env("SMTP_PORT") || "1025"),
31+
username: nil,
32+
password: nil,
33+
ssl: false,
34+
tls: :never,
35+
auth: :never,
36+
retries: 2,
37+
no_mx_lookups: false
38+
39+
# Runtime production configuration, including reading
40+
# of environment variables, is done on config/runtime.exs.

config/prod.exs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ import Config
66
# which you should run after static files are built and
77
# before starting your production server.
88
config :fileonchain, FileonchainWeb.Endpoint,
9-
url: [host: System.get_env("PHX_HOST"), "*.fileonchain.org"],
9+
url: [host: System.get_env("PHX_HOST") || "*.fileonchain.org", host: "*.fileonchain.org"],
1010
render_errors: [
1111
formats: [html: FileonchainWeb.ErrorHTML, json: FileonchainWeb.ErrorJSON],
1212
layout: false
1313
],
1414
cache_static_manifest: "priv/static/cache_manifest.json",
15-
debug_errors: true
15+
debug_errors: true,
16+
check_origin: [
17+
"https://fileonchain.org",
18+
"https://*.fileonchain.org",
19+
"seashell-app-v9acv.ondigitalocean.app"
20+
]
1621

1722
# Configures Swoosh API Client
1823
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Fileonchain.Finch

docker-compose.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,28 @@ services:
4141
context: .
4242
dockerfile: Dockerfile
4343
environment:
44-
MIX_ENV: prod
44+
MIX_ENV: dcompose
4545
DATABASE_URL: ${DATABASE_URL}
4646
SECRET_KEY_BASE: ${SECRET_KEY_BASE}
4747
PHX_HOST: ${PHX_HOST}
48+
SMTP_HOST: smtp
49+
SMTP_PORT: 1025
4850
networks:
4951
- app_network
5052
ports:
5153
- "4000:4000"
5254
depends_on:
5355
- db
56+
- smtp
57+
58+
smtp:
59+
container_name: smtp
60+
image: mailhog/mailhog
61+
networks:
62+
- app_network
63+
ports:
64+
- "1025:1025" # SMTP server
65+
- "8025:8025" # Web UI
5466

5567
networks:
5668
app_network:

lib/fileonchain/accounts/user_notifier.ex

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ defmodule Fileonchain.Accounts.UserNotifier do
88
email =
99
new()
1010
|> to(recipient)
11-
|> from({"Fileonchain", "[email protected]"})
11+
|> from({"Fileonchain", System.get_env("SENDER_EMAIL") || "[email protected]"})
1212
|> subject(subject)
1313
|> text_body(body)
1414

15-
with {:ok, _metadata} <- Mailer.deliver(email) do
16-
{:ok, email}
15+
case Mailer.deliver(email) do
16+
{:ok, _metadata} ->
17+
IO.puts("Email sent successfully to #{recipient}")
18+
{:ok, email}
19+
{:error, reason} ->
20+
IO.puts("Failed to send email to #{recipient}. Reason: #{inspect(reason)}")
21+
{:error, reason}
1722
end
1823
end
1924

0 commit comments

Comments
 (0)