I’m trying to setup an elixir/phoenix/postgres application and having a couple issues. I tried using the Dockerfile from the demo Kurt did for twitter but that kept erroring at the last step and docker isn’t my strong suit.
So… I have lots of heroku experience and I figured lets try out a build pack.
From the docs it looks like i just need something like this in my fly.toml
❯ fly deploy
Deploying fermi
==> Validating app configuration
--> Validating app configuration done
Services
TCP 80/443 ⇢ 8080
==> Building image with Buildpacks
20: Pulling from heroku/buildpacks
Digest: sha256:487fb53b35f9b41b4931eec7c3eb138b605aac13c947ba34731dd2f0d040b3fa
Status: Image is up to date for heroku/buildpacks:20
20: Pulling from heroku/pack
Digest: sha256:e3e29ffe59b09e2d5bcfeaf0497e7765411b56b2b9e392049f94b738b4e6201c
Status: Image is up to date for heroku/pack:20
Downloading from https://github.com/HashNuke/heroku-buildpack-elixir.git
182 KB/-1 B
Error extracting from https://github.com/HashNuke/heroku-buildpack-elixir.git: inspecting buildpack blob: failed to get next tar entry: archive/tar: invalid tar header
Looks like https://cnb-shim.herokuapp.com is down. Might be related to an outage earlier Heroku Status. You’ll need to wait until it’s back up, but I’m going to look into running the shim on fly.
Where I’m at now is that It gets stuck on “DETECTING” but only for the gjaldon/phoenix-static step. Regardless of the order I run them in or if I run them one at a time, or if I try heroku:18 or heroku:20
The hashnuke elixir build pack has no problems detecting and starts the build. It’s extra weird because the detect scripts for both are identical.
The phoenix-static is in the heroku buildpacks:search listing and I downloaded the files the shim downloads just to confirm its not some different version, and it’s identical.
Here are the logs
**❯** fly deploy
**Deploying fermi**
==> Validating app configuration
--> Validating app configuration done
**Services**
TCP 80/443 ⇢ 8080
==> Building image with Buildpacks
18: Pulling from heroku/buildpacks
Digest: sha256:c21a2b9b84990087e17d4a761d7c6520043fbf1bdccf55a1d767b090539834e1
Status: Image is up to date for heroku/buildpacks:18
18: Pulling from heroku/pack
Digest: sha256:90b2e6eeb926bf7bc23e671f0b96a1e8dbbf9f2f2691b890805fbe487ef7b8c2
Status: Image is up to date for heroku/pack:18
Downloading from https://cnb-shim.herokuapp.com/v1/hashnuke/elixir
1.89 MB/-1 B
Downloading from https://cnb-shim.herokuapp.com/v1/gjaldon/phoenix-static
1.88 MB/-1 B
===> DETECTING
err: gjaldon/phoenix-static@0.1 (126)
**ERROR:** No buildpack groups passed detection.
**ERROR:** failed to detect: buildpack(s) failed with err
Error executing lifecycle: failed with status code: 101
Right! I’m fairly sure recent HashNuke Elixir buildpack versions do everything you need. I’ve had success with just that one buildpack on most Phoenix apps.
Been deploying phoenix to heroku for a long time, and its why we have a whole guide devoted to it because it’s so finicky :P.
Nonetheless I tried it out just to see and now it doesn’t appear to have the environment variables set? I have attached a fly postgres to my fermi app, but the DATABASE_URL doesn’t appear to be set during build, when I add a dummy DATABASE_URL to my fly.toml it still yells at me.
MAYBE I need to take another stab at the dockerfile.
Argh yes. We literally have someone starting next week to help make this nicer, for what it’s worth. It is fraught with peril because I’m pretty new at Elixir.
Thank you! Congrats on the hire, looking forward to seeing whom you picked up. There was a lot of chatter about the job. Though maybe I shouldn’t do their job for them :P.
Howdy @peregrine! I joined Fly to help out with the Elixir support. I think the Fly infrastructure is really exciting for running Elixir apps on and I’m looking forward to helping others see the benefits for themselves.
Sorry you’ve been having such a rough time with it. It took me some time (and extra help) getting my first couple Elixir apps deployed on Fly. I’m glad you’ve stuck with it! I’d love to help you get it working. I just started work on a new official guide for getting a new Elixir app deployed so me helping you helps me! So <buzzword>synergy</buzzword>!
I’m working on the Docker approach first. Feel free to DM me and we’ll get you up and running.
@peregrine I created an initial release of the Elixir guide for deploying on Fly. I’d love any feedback (problems/successes) you have with it so I can make it better. Hope it helps!
It’s kind of weird but couldn’t you make a build pack that takes the elixir/erlang/node version config and then uses the above dockerfile?
Basically now that I have this working I’m just going to copy/paste the Dockerfile, Migrations and entrypoint.sh between projects and changing the versions. feels like fly could make elixir a first class citizen this way.
Congrats on the new role @Mark and thanks for the guide! This is exciting - love the podcast and nice to see the Elixir world progress
I just tried following the steps and hit a couple of problems, curious if you can help out:
When I do fly postgres create I have to choose a region other than the one I chose for the app, otherwise I get “Error Can’t create volume, application is already using 1 of 1 zones in fra” . I chose fra for the app itself (delicate-resonance-7851 in case that’s useful and I’m calling the db delicate-db) and am only able to proceed if I choose e.g. ams or cdg.
You are right, the goal is to make Elixir more a first-class experience. Starting with the Dockerfile approach for now. I do have some updates coming today. Including changes to make getting an SSH connection with an IEx shell into a running node working.
@maciejgryka will you try a DB in fra again? Our database was missing some disk capacity so it didn’t think it could give you enough volumes for a pg cluster there.