Elixir Buildpacks Error

Ohh build.args.

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.

1 Like

You should see the list of things we need to do. They’ll appreciate whatever you do today. :slight_smile:

Well if they need help testing the buildpacks and I’m not busy then I’ll be glad to assist.

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>! :slight_smile:

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!



This is good!

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. :stuck_out_tongue: feels like fly could make elixir a first class citizen this way.

1 Like

Congrats on the new role @brainlid and thanks for the guide! This is exciting - love the podcast and nice to see the Elixir world progress :slight_smile:

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.

@maciej 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.

Yeah, works now, thanks @kurt.

1 Like

Quick question as it relates to elixir/live view. For the services.concurrency option do we want any more or less than 1? On 256mb a single elixir instance can concurrently handle a ton of connections and spinning up more instances for 25 open connections seems like a bad idea, especially if you didn’t build your application to do distribution right away.

Is there guidance on how we should handle this?

Starting a new project and I figured I ought to give this guide the ole-copy paste and see how it goes.

System Info:

phoenix master (16-dev)
macos catalina latest, m1
docker desktop 3.3.1

And everything goes fine till deploy when it errors saying:

2021-04-30T14:29:32Z [info] Running: `/app/entrypoint.sh bin/app_name start` as nobody
2021-04-30T14:29:32Z [info] Error: UnhandledIoError(Os { code: 2, kind: NotFound, message: "No such file or directory" })

Which is very confusing because I use the following dockerfile from my previous experiments it’s all good:

# Stage 1: Build a Mix.Release of the application (image size: ~750mb)
FROM bitwalker/alpine-elixir-phoenix:latest AS phx-builder


# These two environment variables will be overwritten when the application is started.
# They are needed here to satisfy the env-variable checks in `prod.secret.exs`

# Cache elixir deps
ADD mix.exs mix.lock ./
RUN mix do deps.get --only prod, deps.compile

# Cache npm deps
ADD assets/package.json assets/
RUN npm install --prefix assets

# Copy all local files to the build context
# Ignores the ones specified in .dockerignore
ADD . .

# Run frontend build, compile, and digest assets
RUN npm run --prefix assets deploy
RUN mix do compile, phx.digest

# Create a Mix.Release of the application
RUN mix release

# Stage 2: Create a smaller deployment image (image size: ~98mb)
FROM bitwalker/alpine-elixir:latest

# Make sure that this PORT is equal to the one above
# and to the one in fly.toml


RUN chown nobody:nobody /app

USER nobody:nobody

# Copy the files necessary to run the application
COPY --from=phx-builder --chown=nobody:nobody /app/_build/prod/rel/app_name ./
COPY --from=phx-builder --chown=nobody:nobody /app/entrypoint.sh ./

ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["bin/app_name", "start"]

I am no expert in docker so I figured I’d share some feedback here.

Is your app actually named app_name? I understand if you changed it for posting here. But that would give a “no such file or directory” error.

Nope just changed it for this post

Looks like your 2nd stage in the Dockerfile doesn’t ADD entrypoint.sh ./, so the entrypoint file doesn’t exist.

Sorry I wasn’t clear in my post.

When I follow your guide dockerfile as added to your docs I get the error.

The Docker I pasted is one that actually works without issue.

Ok. Yes, I see you copy over the entrypoint.sh file from the previous stage. So you do have it there. :slight_smile:

When I’m trying to debug a Dockerfile, I find it helpful to build it locally and get a CLI into it to see if things are where I expect them to be, etc.

docker run -it --rm my_app /bin/ash

This starts the container using ash instead of bash as the shell, since that’s what Alpine Linux uses by default.

Otherwise I don’t know what problem you are hitting.

Ignore my pasted dockerfile completely I was just showing it as an example of what works…

If I use your dockerfile in the official fly docs. I get the error. Just following your guide step by step, only changes are app name.

I updated the guide. Here’s a post that outlines the changes. I can’t promise it will solve your situation, but I hope it helps!