env.sh.eex and what to do with it?

I have 2 projects. One I started 6 months ago on phx@v1.7.2 and some flyctl@0.0.4xxx and 2 days ago with another app phx@v1.7.7 and latest flyctl. Weirdly I have in the later project under ./rel a file called env.sh.eex which is not in my older project.

#!/bin/sh

# configure node for distributed erlang with IPV6 support
export ERL_AFLAGS="-proto_dist inet6_tcp"
export ECTO_IPV6="true"
export DNS_CLUSTER_QUERY="${FLY_APP_NAME}.internal"
export RELEASE_DISTRIBUTION="name"
export RELEASE_NODE="${FLY_APP_NAME}-${FLY_IMAGE_REF##*-}@${FLY_PRIVATE_IP}"

Unfortunately this file only gets mentioned along phx versions prior to v1.6.3 and and now I am wondering if I can delete it in my new project or have to add it to my older one? Both apps seem to run fine, just wanne get it out of the way before I stumble into some weird infrastructure shenanigans in the future and can’t remember this lone file.

Hope someone can give me some insight
best
Denny

Check if you expose/set these variables somewhere else (fly.toml, dockefile)

ECTO_IPV6 and DNS_CLUSTER_QUERY probably explicitly mentioned in your runtime config.
Rest is used to setup BEAM

Do you use distributed erlang for your newer project? also do you host postgres at fly for newer project as well? if yes these vars would be needed

rel/env.sh.eex is a standard mix release file which getes run just before the VM boots. This makes it a great place to do runtime exports related to VM arguments which are only available at runtime – like the machine’s private ip.

In prior flyctl versions, the phoenix launcher appended the ERL_AFLAGS and ECTO_IPV6 to the Dockerfile, but did not set up support for distributed erlang out of the box for you. With the latest flyctl release, the env.sh.eex files prepares apps for distributed clusters out of the box while also ensuring the node names are unique across deployments. So leave this file here, and you can add the GitHub - phoenixframework/dns_cluster: Simple DNS clustering for distributed Elixir nodes dependency to get clustering out of the box.

The next phoenix release will include dns_cluster by default.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.