add emails

This commit is contained in:
2022-02-25 21:35:12 -05:00
parent 34118299e9
commit 6096a420d0
22 changed files with 462 additions and 87 deletions

View File

@ -18,7 +18,8 @@ config :lokal, LokalWeb.Endpoint,
secret_key_base: "KH59P0iZixX5gP/u+zkxxG8vAAj6vgt0YqnwEB5JP5K+E567SsqkCz69uWShjE7I",
render_errors: [view: LokalWeb.ErrorView, accepts: ~w(html json), layout: false],
pubsub_server: Lokal.PubSub,
live_view: [signing_salt: "zOLgd3lr"]
live_view: [signing_salt: "zOLgd3lr"],
registration: System.get_env("REGISTRATION") || "invite"
config :lokal, Lokal.Application, automigrate: false
@ -39,6 +40,15 @@ config :lokal, Lokal.Mailer, adapter: Swoosh.Adapters.Local
# Swoosh API client is needed for adapters other than SMTP.
config :swoosh, :api_client, false
# Gettext
config :gettext, :default_locale, "en_US"
# Configure Oban
config :lokal, Oban,
repo: Lokal.Repo,
plugins: [Oban.Plugins.Pruner],
queues: [default: 10, mailers: 20]
# Configure esbuild (the version is required)
# config :esbuild,
# version: "0.14.0",

View File

@ -2,9 +2,6 @@ import Config
# Configure your database
config :lokal, Lokal.Repo,
url:
System.get_env("DATABASE_URL") ||
"ecto://postgres:postgres@localhost/lokal_dev",
show_sensitive_data_on_connection_error: true,
pool_size: 10
@ -15,13 +12,10 @@ config :lokal, Lokal.Repo,
# watchers to your application. For example, we use it
# with esbuild to bundle .js and .css sources.
config :lokal, LokalWeb.Endpoint,
# Binding to loopback ipv4 address prevents access from other machines.
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
http: [ip: {0, 0, 0, 0}, port: 4000],
check_origin: false,
code_reloader: true,
debug_errors: true,
secret_key_base: "cSLRa17z1D1qLwQuaw73DMT7BX8oDMkru/rJIsmCdlFypLGRQW3bpqJRrZQtoZJQ",
secret_key_base: "dg2lccMgaY3+ZeKppR+ondk4ZRaANZGIN0LMZT1u1uzscH4jO5W9a9b9V9BkC+MW",
watchers: [
# Start the esbuild watcher by calling Esbuild.install_and_run(:default, args)
# esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]}

View File

@ -9,16 +9,7 @@ import Config
# manifest is generated by the `mix phx.digest` task,
# which you should run after static files are built and
# before starting your production server.
config :lokal, LokalWeb.Endpoint,
url: [host: "localhost"],
http: [port: 4000],
cache_static_manifest: "priv/static/cache_manifest.json"
config :lokal, Lokal.Repo,
url: "ecto://postgres:postgres@localhost/lokal",
pool_size: 10
config :lokal, Lokal.Application, automigrate: true
config :lokal, LokalWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
# Do not print debug messages in production
config :logger, level: :info

View File

@ -12,19 +12,49 @@ if System.get_env("PHX_SERVER") && System.get_env("RELEASE_NAME") do
config :lokal, LokalWeb.Endpoint, server: true
end
if config_env() == :prod do
database_url =
config :lokal, LokalWeb.ViewHelpers, shibao_mode: System.get_env("SHIBAO_MODE") == "true"
# Set locale
Gettext.put_locale(System.get_env("LOCALE") || "en_US")
maybe_ipv6 = if System.get_env("ECTO_IPV6") == "true", do: [:inet6], else: []
database_url =
if config_env() == :test do
System.get_env("TEST_DATABASE_URL") ||
"ecto://postgres:postgres@localhost/lokal_test#{System.get_env("MIX_TEST_PARTITION")}"
else
System.get_env("DATABASE_URL") ||
"ecto://postgres:postgres@lokal-db/lokal"
end
maybe_ipv6 = if System.get_env("ECTO_IPV6"), do: [:inet6], else: []
host =
System.get_env("HOST") ||
raise "No hostname set! Must be the domain and tld like `lokal.bubbletea.dev`."
config :lokal, Lokal.Repo,
# ssl: true,
url: database_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
socket_options: maybe_ipv6
interface =
if config_env() in [:dev, :test],
do: {0, 0, 0, 0},
else: {0, 0, 0, 0, 0, 0, 0, 0}
config :lokal, Lokal.Repo,
# ssl: true,
url: database_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
socket_options: maybe_ipv6
config :lokal, LokalWeb.Endpoint,
url: [scheme: "https", host: host, port: 443],
http: [
# See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
ip: interface,
port: String.to_integer(System.get_env("PORT") || "4000")
],
server: true,
registration: System.get_env("REGISTRATION") || "invite"
if config_env() == :prod do
# The secret key base is used to sign/encrypt cookies and other secrets.
# A default value is used in config/dev.exs and config/test.exs but you
# want to use a different value for prod and you most likely don't want
@ -37,20 +67,21 @@ if config_env() == :prod do
You can generate one by calling: mix phx.gen.secret
"""
host = System.get_env("HOST") || "localhost"
config :lokal, LokalWeb.Endpoint, secret_key_base: secret_key_base
config :lokal, LokalWeb.Endpoint,
ururl: [scheme: "https", host: host, port: 443],
http: [
# Enable IPv6 and bind on all interfaces.
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
# See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: String.to_integer(System.get_env("PORT") || "4000")
],
secret_key_base: secret_key_base,
server: true
# Automatically apply migrations
config :lokal, Lokal.Application, automigrate: true
# Set up SMTP settings
config :lokal, Lokal.Mailer,
adapter: Swoosh.Adapters.SMTP,
relay: System.get_env("SMTP_HOST") || raise("No SMTP_HOST set!"),
port: System.get_env("SMTP_PORT") || 587,
username: System.get_env("SMTP_USERNAME") || raise("No SMTP_USERNAME set!"),
password: System.get_env("SMTP_PASSWORD") || raise("No SMTP_PASSWORD set!"),
ssl: System.get_env("SMTP_SSL") == "true",
email_from: System.get_env("EMAIL_FROM") || "no-reply@#{System.get_env("HOST")}",
email_name: System.get_env("EMAIL_NAME") || "Lokal"
# ## Using releases
#
@ -61,22 +92,4 @@ if config_env() == :prod do
#
# Then you can assemble a release by calling `mix release`.
# See `mix help release` for more information.
# ## Configuring the mailer
#
# In production you need to configure the mailer to use a different adapter.
# Also, you may need to configure the Swoosh API client of your choice if you
# are not using SMTP. Here is an example of the configuration:
#
# config :lokal, Lokal.Mailer,
# adapter: Swoosh.Adapters.Mailgun,
# api_key: System.get_env("MAILGUN_API_KEY"),
# domain: System.get_env("MAILGUN_DOMAIN")
#
# For this example you need include a HTTP client required by Swoosh API client.
# Swoosh supports Hackney and Finch out of the box:
#
# config :swoosh, :api_client, Swoosh.ApiClient.Hackney
#
# See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
end

View File

@ -1,14 +1,14 @@
import Config
# Only in tests, remove the complexity from the password hashing algorithm
config :bcrypt_elixir, :log_rounds, 1
# Configure your database
#
# The MIX_TEST_PARTITION environment variable can be used
# to provide built-in test partitioning in CI environment.
# Run `mix help test` for more information.
config :lokal, Lokal.Repo,
url:
System.get_env("TEST_DATABASE_URL") ||
"ecto://postgres:postgres@localhost/lokal_test#{System.get_env("MIX_TEST_PARTITION")}",
pool: Ecto.Adapters.SQL.Sandbox,
pool_size: 10
@ -16,7 +16,7 @@ config :lokal, Lokal.Repo,
# you can enable the server option below.
config :lokal, LokalWeb.Endpoint,
http: [ip: {0, 0, 0, 0}, port: 4002],
secret_key_base: "T4DkRImgeMNCcPcTWBCZyKYp3KQ8yyPD33VT4wj6ogbP8fIGUsqmOTNX3clTMrLo",
secret_key_base: "S3qq9QtUdsFtlYej+HTjAVN95uP5i5tf2sPYINWSQfCKJghFj2B1+wTAoljZyHOK",
server: false
# In test we don't send emails.
@ -27,3 +27,6 @@ config :logger, level: :warn
# Initialize plugs at runtime for faster test compilation
config :phoenix, :plug_init_mode, :runtime
# Disable Oban
config :lokal, Oban, queues: false, plugins: false