Prod packaging v1 (#23)

* Sets media directory for prod

* Improved logging; Added docker files for prod

* Improved fetching SECRET_KEY_BASE for selfhosted instances
This commit is contained in:
Kieran
2024-02-16 18:50:00 -08:00
committed by GitHub
parent b81c8d64b3
commit 1f56db01a5
13 changed files with 234 additions and 16 deletions
+2
View File
@@ -21,6 +21,8 @@ defmodule Pinchflat.Application do
PinchflatWeb.Endpoint
]
:ok = Oban.Telemetry.attach_default_logger()
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Pinchflat.Supervisor]
@@ -30,7 +30,7 @@ defmodule Pinchflat.MediaClient.Backends.YtDlp.CommandRunner do
print_to_file_opts = [{:print_to_file, output_template}, json_output_path]
formatted_command_opts = [url] ++ parse_options(command_opts ++ print_to_file_opts)
Logger.debug("[yt-dlp] called with: #{Enum.join(formatted_command_opts, " ")}")
Logger.info("[yt-dlp] called with: #{Enum.join(formatted_command_opts, " ")}")
case System.cmd(command, formatted_command_opts, stderr_to_stdout: true) do
{_, 0} ->
+28
View File
@@ -0,0 +1,28 @@
defmodule Pinchflat.Release do
@moduledoc """
Used for executing DB release tasks when run in production without Mix
installed.
"""
@app :pinchflat
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