Initial Phoenix App with Fly.io

This commit is contained in:
2023-03-02 18:40:10 +02:00
commit 0853da9826
54 changed files with 1984 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
defmodule Osuuspuutarha.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
children = [
# Start the Ecto repository
Osuuspuutarha.Repo,
# Start the Telemetry supervisor
OsuuspuutarhaWeb.Telemetry,
# Start the PubSub system
{Phoenix.PubSub, name: Osuuspuutarha.PubSub},
# Start the Endpoint (http/https)
OsuuspuutarhaWeb.Endpoint
# Start a worker by calling: Osuuspuutarha.Worker.start_link(arg)
# {Osuuspuutarha.Worker, arg}
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Osuuspuutarha.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
@impl true
def config_change(changed, _new, removed) do
OsuuspuutarhaWeb.Endpoint.config_change(changed, removed)
:ok
end
end

View File

@@ -0,0 +1,3 @@
defmodule Osuuspuutarha.Mailer do
use Swoosh.Mailer, otp_app: :osuuspuutarha
end

View File

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

@@ -0,0 +1,5 @@
defmodule Osuuspuutarha.Repo do
use Ecto.Repo,
otp_app: :osuuspuutarha,
adapter: Ecto.Adapters.Postgres
end