move more fully to runtime config with release, improved docker build, updated phx liveview js

This commit is contained in:
Adam Piontek 2023-01-28 08:14:32 -05:00
commit 573a1e9cfe
38 changed files with 428 additions and 205 deletions
lib/shift73k

View file

@ -1,16 +1,13 @@
defmodule Shift73k.Mailer.UserEmail do
import Swoosh.Email
import Shift73k, only: [get_app_mailer_from: 0, get_app_mailer_reply_to: 0]
@mailer_vars Application.compile_env(:shift73k, :app_global_vars,
mailer_reply_to: "admin@example.com",
mailer_from: {"Shift73k", "shift73k@example.com"}
)
def compose(user_email, subject, body_text) do
new()
|> from(@mailer_vars[:mailer_from])
|> from(get_app_mailer_from())
|> to(user_email)
|> header("Reply-To", @mailer_vars[:mailer_reply_to])
|> header("Reply-To", get_app_mailer_reply_to())
|> subject(subject)
|> text_body(body_text)
end

28
lib/shift73k/release.ex Normal file
View file

@ -0,0 +1,28 @@
defmodule Shift73k.Release do
@moduledoc """
Used for executing DB release tasks when run in production without Mix
installed.
"""
@app :shift73k
def migrate do
load_app()
for repo <- repos() do
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
end
end
def rollback(repo, version) do
load_app()
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
end
defp repos do
Application.fetch_env!(@app, :ecto_repos)
end
defp load_app do
Application.load(@app)
end
end

View file

@ -1,7 +1,7 @@
defmodule Shift73k.Shifts.Templates.ShiftTemplate do
use Ecto.Schema
import Ecto.Changeset
import Shift73k, only: [app_time_zone: 0]
import Shift73k, only: [get_app_time_zone: 0]
alias Shift73k.Shifts
alias Shift73k.Shifts.Templates.ShiftTemplate
@ -12,7 +12,7 @@ defmodule Shift73k.Shifts.Templates.ShiftTemplate do
field :subject, :string
field :description, :string
field :location, :string
field :time_zone, :string, default: app_time_zone()
field :time_zone, :string, default: get_app_time_zone()
field :time_start, :time, default: ~T[09:00:00]
field :time_end, :time, default: ~T[17:00:00]