Problems with the Elixir tutorial

Hi folks! I’ve heard nothing but good things about Fly and wanted to give it a spin. I encountered a few issues following this tutorial and wanted to report them.

  1. The base image in the Dockerfile didn’t exist on Docker Hub. Running mix hello_elixir created an application template, and it included a Dockerfile since I was running on Phoenix v1.6.11. This Dockerfile depended on the image hexpm/elixir:1.14.0-erlang-25.0.4-debian-bullseye-20210902-slim, which did not exist on Docker Hub, and was causing errors on my build process. I changed it to hexpm/elixir:1.14.0-erlang-25.0.4-debian-bullseye-20220801-slim, which did exist and works.
  2. I had to run fly doctor twice, out of the box. Something about my local setup prevented me from connecting to Wireguard? I’m not 100% sure I understand how WG is used in the Fly build process, but I was getting weird errors with builds and I guess I needed to ensure WG could get thru the firewall.
  3. I got stuck with some error about my DATABASE_URL being unset. I tried this multiple times, but it didn’t ever work. While deploying my app, Fly is supposed to automatically configure DATABASE_URL after it spins up a Postgres database in the above tutorial. This never worked. I tried several times (even between deleting and recreating the app with the same and different names.) The failure modes varied wildly:
    • The app wouldn’t appear at all in the Fly dashboard
    • The app would appear, but wouldn’t have any secrets associated
    • The app would appear, a secret was present (I manually associated one once) and it still crashed with an error in the logs about no database URL being present.

I’m running macOS 12.3.1 on an M1 chip, Elixir and flyctl were both installed from brew. My most recent test was an app with the autogenerated name of little-bush-7241, which I’ve since deleted.

I’m not sure how much help I’ll be able to be for troubleshooting, but I wanted to report this since it was a really frustrating experience.

Hi @weaver!

Sorry to hear you’ve had some challenges with your initial experience.

I wanted to test this out myself and see if there are any issues we can help address.

Database URL

During the fly launch process, it prompts to deploy a Postgres database. Looks like this:

Detected a Phoenix app
? App Name (leave blank to use an auto-generated name): 
? Select organization: My Name (personal)
? Select region: lax (Los Angeles, California (US))
Created app patient-leaf-5806 in organization personal
Set secrets on patient-leaf-5806: SECRET_KEY_BASE
Preparing system for Elixir builds
Installing application dependencies
Running Docker release generator
Wrote config file fly.toml
? Would you like to set up a Postgresql database now? Yes

I believe it defaults to “No” on the last prompt. Without a database being setup during the launch, you’ll have to setup it yourself. The DATABASE_URL secret is set during the fly postgres attach command (see doc link for usage).

After it deploys the Postgres cluster, it logs out something like this:

Postgres cluster patient-leaf-5806-db is now attached to patient-leaf-5806
The following secret was added to patient-leaf-5806:
Postgres cluster patient-leaf-5806-db is now attached to patient-leaf-5806


The problem with the Dockerfile is real. During the fly launch process, it detects that it’s a Phoenix app and runs mix phx.gen.release which “generates release files and optional Dockerfile for release-based deployments”.

The Phoenix generator is creating a Dockerfile that links to a public image that, we’ve now discovered, doesn’t always work. Here’s a link to the Phoenix generator: phoenix/Dockerfile.eex at master · phoenixframework/phoenix · GitHub. It assumes a Elixir+Erlang version on an older 2021 Bullseye base image is available. This combo (Elixir 1.14 + Erlang 25.0.4) doesn’t exist. So this is a shortcoming with the Dockerfile generator and/or the Hexpm Bob builder. I created a PR against Phoenix to update this.

Here’s a list of supported Dockerfile images: Docker Hub

After updating the Dockerfile to be valid image, it correctly deployed and worked. Using fly deploy.

Fly Doctor

I’m not on a Mac, but fly doctor didn’t have any issues for me.

$ fly version
flyctl v0.0.387 linux/amd64 Commit: d46c14f3 BuildDate: 2022-09-01T21:55:51Z

Thank you for reporting the issues! The Docker one is a little stinker. Hopefully that can be resolved soon.

@Mark I changed the docker version to the correct debian version and still does not work for me. I have more details in this thread.

Hi @Mark! Thanks for chasing a few of these things down for me!

To confirm, I did select “Yes” to the creation of a PostgreSQL database, and still experienced the deployment complaining about that environment variable not being set. I also experienced it when I set that variable manually, so I definitely still think something is up…

The other two issues make sense… thanks!

1 Like

I can confirm that I needed to change the following fields to get the project to build/deploy:


It looks like the Elixier was set to version 1.13.x and OTP version is set to a previous version. Matching the above versions + ARG DEBIAN_VERSION=bullseye-20220801-slim had the project build as expected.

does this have something to do with Phoenix’s recent version (1.16.12)?

1.6.12 (2022-09-06)

  • Fix phx.gen.release Dockerfile pointing to expired image

That’s the PR & change Mark references.

Hi @aboutaaron,

The Phoenix mix task that generated the Dockerfile is actually looking at your local Elixir and OTP versions to use those. That particular combination may not exist as a tagged Docker image.

I believe some upstream effort is being made to try and solve this in a more predictable way for people. But yes, your approach of fixing the versions is good.