Yeah, works now, thanks @kurt.
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:
elixir-1.11
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
WORKDIR /app
# 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`
ENV SECRET_KEY_BASE=nokey
ENV DATABASE_URL=nodb
ENV PORT=4000
ENV MIX_ENV=prod
# 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
ENV PORT=4000
ENV MIX_ENV=prod
ENV SECRET_KEY_BASE=nokey
WORKDIR /app
RUN chown nobody:nobody /app
USER nobody:nobody
ENV HOME=/app
# 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.
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!