Hey everyone, I’m hoping you’ll be able to help me with an Elixir Releases issue. I searched the forums for a similar
post, but the one I found, doesn’t apply as the
issue there was a typo.
So, I’m building and following the instructions from here. I’m able to go through
all the steps it outlines without any issues, but since my app is an umbrella application I had to make
a few modifications. Here’s the make target I made to consolidate the steps:
.PHONY: release-build
## release-build: builds a local release version of the app
release-build:
mix deps.get --only prod && \
MIX_ENV=prod mix compile && \
npm install --prefix apps/my_app_web/assets && \
npm run deploy --prefix apps/my_app_web/assets && \
mix phx.digest && \
MIX_ENV=prod mix release --overwrite
My mix.exs
file with the release configuration of the release looks like this (with the actual app’s name removed):
defp releases do
[
my_app_web: [
include_executables_for: [:unix],
applications: [
runtime_tools: :permanent
]
]
]
end
The release is built and run on macOS Catalina 10.15.7. Now, the build works and the _build/prod
directory gets
generated without any issues, but when I try starting it with _build/prod/rel/my_app_web/bin/my_app_web start
the application
seems like it’s running, but I can’t navigate to the landing page in my browser.
Here’s how I have everything configured:
Elixir is version:
Erlang/OTP 23 [erts-11.1.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [dtrace]
Elixir 1.11.1 (compiled with Erlang/OTP 23)
and Phoenix version is 1.5.4. I’m using Runtime Configuration which seems to be set properly when I start-up iex:
# config/runtime.exs file
import Config
if config_env() == :prod do
config :my_app_web,
MyAppWeb.Endpoint,
server: true,
http: [
port: String.to_integer(System.fetch_env!("MA_PORT")),
transport_options: [
socket_opts: [:inet6]
]
],
secret_key_base: System.fetch_env!("MA_SECRET_KEY_BASE"),
basic_auth: [
username: System.fetch_env!("MA_BASIC_AUTH_USERNAME"),
password: System.fetch_env!("MA_BASIC_AUTH_PASSWORD")
]
config :my_app,
MyApp.Repo,
url: System.fetch_env!("MA_DATABASE_URL")
end
# :my_app_web config
[
{MyAppWeb.Endpoint,
[
render_errors: [
view: MyAppWeb.ErrorView,
accepts: ["html", "json"],
layout: false
],
pubsub_server: MyApp.PubSub,
live_view: [signing_salt: "signing_salt"],
url: [host: "MyApp.com", port: 80],
cache_static_manifest: "priv/static/cache_manifest.json",
server: true,
http: [port: 8080, transport_options: [socket_opts: [:inet6]]],
secret_key_base: "secret_key_base",
basic_auth: [username: "admin", password: "admin"]
]}
]
# :my_app config
[
{:generators, [context_app: false]},
{MyApp.Repo,
[url: "ecto://postgres:postgres@localhost/my_app_development"]},
{:ecto_repos, [MyApp.Repo]}
]
What is interesting is that if I start the app with _build/prod/rel/my_app_web/bin/my_app_web start_iex
and then
try to call a function on one of my modules, say MyApp.Marketing.LifeCoachingLeads.list_life_coaching_leads
, then I get:
** (UndefinedFunctionError) function MyApp.Marketing.LifeCoachingLeads.list_life_coaching_leads/0 is undefined (module MyApp.Marketing.LifeCoachingLeads is not available)
MyApp.Marketing.LifeCoachingLeads.list_life_coaching_leads()
Which makes me think my release isn’t finding the modules it needs to start up, but it’s not obvious to me why.
Any pointers in the right direction would be fantastic!