Unable to deploy Phoenix App, child exited normally with code: 1 after preparing to run migrate

Hey guys,
I’m sure I’m missing something obvious but this deploy style is really new to me. Got the deploy almost running smoothly but I get a child exited normally with code: 1

I think I may have set up the files wrong, but I’m quite stumped. Not really sure what more I can do to trouble shoot this. So, I’m hoping I can get some help. Apologies if the answer is obvious. Still trying to grasp this concept of fly’s deploy style with elixir.

Here’s the error code I’m getting

Command: /app/bin/serotana_ex eval SerotanaEx.Release.migrate
         Starting instance
         Configuring virtual machine
         Pulling container image
         Unpacking image
         Preparing kernel init
         Configuring firecracker
         Starting virtual machine
         Starting init (commit: 50ffe20)...
         Preparing to run: `bin/serotana_ex /app/bin/serotana_ex eval SerotanaEx.Release.migrate` as elixir
         2021/09/28 11:32:36 listening on [fdaa:0:34c0:a7b:23c6:ebae:5cb1:2]:22 (DNS: [fdaa::3]:53)
         Main child exited normally with code: 1
         Starting clean up.

Here’s my docker which I think is working


ARG MIX_ENV="prod"

FROM hexpm/elixir:1.12.1-erlang-24.0.1-alpine-3.13.3 AS build

# install build dependencies

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

# prepare build dir

WORKDIR /app

# install hex + rebar

RUN mix local.hex --force && \

mix local.rebar --force

# set build ENV

ARG MIX_ENV

ENV MIX_ENV="${MIX_ENV}"

# install mix dependencies

COPY mix.exs mix.lock ./

RUN mix deps.get --only $MIX_ENV

RUN mkdir config

# copy compile-time config files before we compile dependencies

# to ensure any relevant config change will trigger the dependencies

# to be re-compiled.

COPY config/config.exs config/$MIX_ENV.exs config/

RUN mix deps.compile

COPY priv priv

# note: if your project uses a tool like https://purgecss.com/,

# which customizes asset compilation based on what it finds in

# your Elixir templates, you will need to move the asset compilation

# step down so that `lib` is available.

COPY assets assets

RUN mix assets.deploy

# compile and build the release

COPY lib lib

RUN mix compile

# changes to config/runtime.exs don't require recompiling the code

COPY config/runtime.exs config/

# uncomment COPY if rel/ exists

# COPY rel rel

RUN mix release

# start a new build stage so that the final image will only contain

# the compiled release and other runtime necessities

FROM alpine:3.12.1 AS app

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

ARG MIX_ENV

ENV USER="elixir"

WORKDIR "/home/${USER}/app"

# Creates an unprivileged user to be used exclusively to run the Phoenix app

RUN \

addgroup \

-g 1000 \

-S "${USER}" \

&& adduser \

-s /bin/sh \

-u 1000 \

-G "${USER}" \

-h "/home/${USER}" \

-D "${USER}" \

&& su "${USER}"

# Everything from this line onwards will run in the context of the unprivileged user.

USER "${USER}"

COPY --from=build --chown="${USER}":"${USER}" /app/_build/"${MIX_ENV}"/rel/serotana_ex ./

ENTRYPOINT ["bin/serotana_ex"]

# Usage:

# * build: sudo docker image build -t elixir/serotana_ex .

# * shell: sudo docker container run --rm -it --entrypoint "" -p 127.0.0.1:4000:4000 elixir/serotana_ex sh

# * run: sudo docker container run --rm -it -p 127.0.0.1:4000:4000 --name serotana_ex elixir/serotana_ex

# * exec: sudo docker container exec -it serotana_ex sh

# * logs: sudo docker container logs --follow --tail 100 serotana_ex

CMD ["start"]

And here’s my toml

# fly.toml file generated for purple-star-1428 on 2021-09-27T17:53:17+02:00

app = "purple-star-1428"

kill_signal = "SIGTERM"
kill_timeout = 5

[env]

[deploy]
  release_command = "/app/bin/serotana_ex eval SerotanaEx.Release.migrate"

[[services]]
  internal_port = 4000
  protocol = "tcp"

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "60s" # allow some time for startup
    interval = "15s"
    restart_limit = 6
    timeout = "2s"

I’m not sure what else to check, and thank you for your help in advance

Can you try:

[deploy]
  release_command = "eval SerotanaEx.Release.migrate"

I think the release_command only overrides the CMD, not ENTRYPOINT.

Hey Jerome! Goodness that did the trick! I think I’ll need to study docker a bit more so I can understand everything I’m writing and working with.

Appreciate the quick response!

1 Like

This is possibly an issue on our end. At least it should be documented somewhere.