Skip to content

Commit

Permalink
changes to facilitate deployment on render.com
Browse files Browse the repository at this point in the history
  • Loading branch information
brianflanagan committed Jan 14, 2025
1 parent eecef8a commit 11c3306
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
13 changes: 13 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# exit on error
set -o errexit

# Initial setup
mix deps.get --only prod
MIX_ENV=prod mix compile

MIX_ENV=prod mix assets.build
MIX_ENV=prod mix assets.deploy

MIX_ENV=prod mix phx.gen.release
MIX_ENV=prod mix release --overwrite
2 changes: 1 addition & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if config_env() == :prod do
You can generate one by calling: mix phx.gen.secret
"""

host = System.get_env("PHX_HOST") || "example.com"
host = System.get_env("RENDER_EXTERNAL_HOSTNAME") || "localhost"
port = String.to_integer(System.get_env("PORT") || "4000")

config :ppr_api, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
Expand Down
28 changes: 28 additions & 0 deletions lib/ppr_api/release.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
defmodule PprApi.Release do
@moduledoc """
Used for executing DB release tasks when run in production without Mix
installed.
"""
@app :ppr_api

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

0 comments on commit 11c3306

Please sign in to comment.