feat: use release to deploy application

Adjust `Dockerfile` and `docker-compose` to use the `release` structure.
This commit is contained in:
2024-09-20 21:16:32 +00:00
parent 964985e328
commit 76d5fc9adf
7 changed files with 109 additions and 6 deletions

28
lib/wabanex/release.ex Normal file
View File

@@ -0,0 +1,28 @@
defmodule Wabanex.Release do
@moduledoc """
Used for executing DB release tasks when run in production without Mix
installed.
"""
@app :wabanex
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