Phoenix on Alpine Linux?

I’m trying to deploy on Alpine
Build looks fine, but I couldn’t spin up the server. Deployment says success but server doesn’t respond.
I’ve got bin/server and bin/migrate from flyctl launch, maybe this is problem?

# bin/server
cd -P -- "$(dirname -- "$0")"
PHX_SERVER=true exec ./feder start

Is this supposed to work in Alpine?
Below is the Dockerfile

FROM elixir:alpine AS builder

ENV MIX_ENV="prod"

RUN apk add --no-cache build-base git


RUN mix local.hex --force && \
    mix local.rebar --force

COPY mix.exs mix.lock ./
RUN mix deps.get --only $MIX_ENV

RUN mkdir config

COPY config/config.exs config/$MIX_ENV.exs config/
RUN mix deps.compile

COPY priv priv
COPY assets assets
RUN mix assets.deploy

COPY lib lib
RUN mix compile

COPY config/runtime.exs config/
COPY rel rel
RUN mix release

FROM alpine:3.16 AS runner

ENV MIX_ENV="prod"
ENV ERL_AFLAGS "-proto_dist inet6_tcp"

RUN apk add --no-cache libstdc++ ncurses-libs openssl


COPY --from=builder /app/_build/${MIX_ENV}/rel/feder ./

ENTRYPOINT [ "bin/server" ]

Hi @taronull,

I’ve successfully used Alpine Linux in the past. However, because of DNS config issues in Alpine, at Fly we’ve been recommending people use a Debian based image. You may not have that problem though.

Instead of:


CMD ["/app/bin/server"]
1 Like

Thank you so much! CMD solved it. I have further questions about the DNS issue.
If I keep using Alpine, will I bump into DNS config issues as my Phoenix project grows bigger?
What makes me free from the issue at the moment? Is it Phoenix?
And where can I learn about this issue?

Hi @taronull!

I’m glad that resolved the issue for you!

Sorry, I don’t have a good link for the DNS problem in Alpine, as I understand it, they were not acknowledging that there was an issue. However, this post gives some info about it.

I can’t say if you’ll have a problem or not! :man_shrugging: