SECRET_KEY_BASE missing error even though it isn't

I’ve been trying to deploy my umbrella app for longer than a week now but every time having a different issue which is driving me crazy now.

I’ve got a Dockerfile which is used for the deployment. Once I deploy the app I get this weird error in logs saying that SECRET_KEY_BASE doesn’t exist however it’s already in my secrets. I am not sure what the problem is.

I can even see the SECRET_KEY_BASE environment variable when I ssh into the server and run env.

Could you please help?

Logs

$ fly logs -a wild-fog-4280

Waiting for logs...

2022-06-24T01:25:03.726 app[14fdfcd4] fra [info] (elixir 1.13.4) src/elixir.erl:274: :elixir.eval_forms/3

2022-06-24T01:25:03.726 app[14fdfcd4] fra [info] (elixir 1.13.4) lib/code.ex:404: Code.validated_eval_string/3

2022-06-24T01:25:03.726 app[14fdfcd4] fra [info] (elixir 1.13.4) lib/config.ex:260: Config.__eval__!/3

2022-06-24T01:25:03.726 app[14fdfcd4] fra [info] (elixir 1.13.4) lib/config/reader.ex:92: Config.Reader.read!/2

2022-06-24T01:25:03.732 app[14fdfcd4] fra [info] {"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.RuntimeError',message=><<101,110,118,105,114,111,110,109,101,110,116,32,118,97,114,105,97,98,108,101,32,83,69,67,82,69,84,95,75,69,89,95,66,65,83,69,32,105,115,32,109,105,115,115,105,110,103,46,10,89,111,117,32,99,97,110,32,103,101,110,101,114,97,116,101,32,111,110,101,32,98,121,32,99,97,108,108,105,110,103,58,32,109,105,120,32,112,104,120,46,103,101,110,46,115,101,99,114,101,116,10>>},[{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,685},{error_info,#{module=>'Elixir.Exception'}}]},{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,446}]},{erl_eval,exprs,5,[{file,"erl_eval.erl"},{line,123}]},{elixir,recur_eval,3,[{file,"src/elixir.erl"},{line,296}]},{elixir,eval_forms,3,[{file,"src/elixir.erl"},{line,274}]},{'Elixir.Code',validated_eval_string,3,[{file,"lib/code.ex"},{line,404}]},{'Elixir.Config','__eval__!',3,[{file,"lib/config.ex"},{line,260}]},{'Elixir.Config.Reader','read!',2,[{file,"lib/config/reader.ex"},{line,92}]}]}}

2022-06-24T01:25:03.733 app[14fdfcd4] fra [info] init terminating in do_boot ({,[{erl_eval,do_apply,6,[{_},{_},{_}]},{erl_eval,expr,5,[{_},{_}]},{erl_eval,exprs,5,[{_},{_}]},{elixir,recur_eval,3,[{_},{_}]},{elixir,eval_forms,3,[{_},{_}]},{Elixir.Code,validated_eval_string,3,[{_},{_}]},{Elixir.Config,__eval__!,3,[{_},{_}]},{Elixir.Config.Reader,read!,2,[{_},{_}]}]})

2022-06-24T01:25:03.875 app[14fdfcd4] fra [info] Crash dump is being written to: erl_crash.dump...done

2022-06-24T01:25:04.255 app[14fdfcd4] fra [info] Main child exited normally with code: 1

2022-06-24T01:25:04.255 app[14fdfcd4] fra [info] Reaped child process with pid: 570 and signal: SIGUSR1, core dumped? false

2022-06-24T01:25:04.256 app[14fdfcd4] fra [info] Starting clean up.

2022-06-24T01:26:10.479 runner[eac8983d] fra [info] Starting instance

2022-06-24T01:26:11.438 runner[eac8983d] fra [info] Configuring virtual machine

2022-06-24T01:26:11.441 runner[eac8983d] fra [info] Pulling container image

2022-06-24T01:26:14.391 runner[eac8983d] fra [info] Unpacking image

2022-06-24T01:26:15.823 runner[eac8983d] fra [info] Preparing kernel init

2022-06-24T01:26:16.439 runner[eac8983d] fra [info] Configuring firecracker

2022-06-24T01:26:16.536 runner[eac8983d] fra [info] Starting virtual machine

2022-06-24T01:26:16.794 app[eac8983d] fra [info] Starting init (commit: e21acb3)...

2022-06-24T01:26:16.815 app[eac8983d] fra [info] Preparing to run: `bin/dert_gg_web start` as nobody

2022-06-24T01:26:16.825 app[eac8983d] fra [info] 2022/06/24 01:26:16 listening on [fdaa:0:6e5f:a7b:67:eac8:983d:2]:22 (DNS: [fdaa::3]:53)

2022-06-24T01:26:17.821 app[eac8983d] fra [info] Reaped child process with pid: 549, exit code: 0

2022-06-24T01:26:20.603 app[eac8983d] fra [info] 01:26:20.602 [info] Running DertGGWeb.Endpoint with cowboy 2.9.0 at :::4000 (http)

2022-06-24T01:26:20.605 app[eac8983d] fra [info] 01:26:20.604 [info] Access DertGGWeb.Endpoint at http://example.com

2022-06-24T01:26:20.825 app[eac8983d] fra [info] Reaped child process with pid: 570 and signal: SIGUSR1, core dumped? false

2022-06-24T01:26:25.608 app[eac8983d] fra [info] 01:26:25.607 [info] tzdata release in place is from a file last modified Fri, 22 Oct 2021 02:20:47 GMT. Release file on server was last modified Wed, 16 Mar 2022 13:36:02 GMT.

2022-06-24T01:26:27.161 app[eac8983d] fra [info] 01:26:27.160 [info] Tzdata has updated the release from 2021e to 2022a

2022-06-24T01:51:26.312 runner[eac8983d] fra [info] Shutting down virtual machine

2022-06-24T01:51:26.521 app[eac8983d] fra [info] Sending signal SIGINT to main child process w/ PID 515

2022-06-24T01:51:26.525 app[eac8983d] fra [info] BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo

2022-06-24T01:51:26.525 app[eac8983d] fra [info] (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution

2022-06-24T01:51:27.526 app[eac8983d] fra [info] Rein child exited normally with code: 0

2022-06-24T01:51:27.527 app[eac8983d] fra [info] Seaped child process with pid: 572 and signal: SIGUSR1, core dumped? false

2022-06-24T01:51:27.527 app[eac8983d] fra [info] Starting clean up.

2022-06-24T01:51:30.362 runner[3fdb11b8] fra [info] Starting instance

2022-06-24T01:51:30.969 runner[3fdb11b8] fra [info] Configuring virtual machine

2022-06-24T01:51:30.995 runner[3fdb11b8] fra [info] Pulling container image

2022-06-24T01:51:33.798 runner[3fdb11b8] fra [info] Unpacking image

2022-06-24T01:51:35.236 runner[3fdb11b8] fra [info] Preparing kernel init

2022-06-24T01:51:35.924 runner[3fdb11b8] fra [info] Configuring firecracker

2022-06-24T01:51:36.033 runner[3fdb11b8] fra [info] Starting virtual machine

2022-06-24T01:51:36.271 app[3fdb11b8] fra [info] Starting init (commit: e21acb3)...

2022-06-24T01:51:36.293 app[3fdb11b8] fra [info] Preparing to run: `bin/dert_gg_web start` as nobody

2022-06-24T01:51:36.312 app[3fdb11b8] fra [info] 2022/06/24 01:51:36 listening on [fdaa:0:6e5f:a7b:67:3fdb:11b8:2]:22 (DNS: [fdaa::3]:53)

2022-06-24T01:51:37.304 app[3fdb11b8] fra [info] Reaped child process with pid: 549, exit code: 0

2022-06-24T01:51:39.885 app[3fdb11b8] fra [info] ERROR! Config provider Config.Reader failed with:

2022-06-24T01:51:39.886 app[3fdb11b8] fra [info] ** (RuntimeError) environment variable SECRET_KEY_BASE is missing.

2022-06-24T01:51:39.886 app[3fdb11b8] fra [info] You can generate one by calling: mix phx.gen.secret

2022-06-24T01:51:39.886 app[3fdb11b8] fra [info] (stdlib 3.17.2) erl_eval.erl:685: :erl_eval.do_apply/6

2022-06-24T01:51:39.886 app[3fdb11b8] fra [info] (stdlib 3.17.2) erl_eval.erl:446: :erl_eval.expr/5

2022-06-24T01:51:39.886 app[3fdb11b8] fra [info] (stdlib 3.17.2) erl_eval.erl:123: :erl_eval.exprs/5

2022-06-24T01:51:39.886 app[3fdb11b8] fra [info] (elixir 1.13.4) src/elixir.erl:296: :elixir.recur_eval/3

2022-06-24T01:51:39.886 app[3fdb11b8] fra [info] (elixir 1.13.4) src/elixir.erl:274: :elixir.eval_forms/3

2022-06-24T01:51:39.886 app[3fdb11b8] fra [info] (elixir 1.13.4) lib/code.ex:404: Code.validated_eval_string/3

2022-06-24T01:51:39.886 app[3fdb11b8] fra [info] (elixir 1.13.4) lib/config.ex:260: Config.__eval__!/3

2022-06-24T01:51:39.886 app[3fdb11b8] fra [info] (elixir 1.13.4) lib/config/reader.ex:92: Config.Reader.read!/2

2022-06-24T01:51:39.893 app[3fdb11b8] fra [info] {"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.RuntimeError',message=><<101,110,118,105,114,111,110,109,101,110,116,32,118,97,114,105,97,98,108,101,32,83,69,67,82,69,84,95,75,69,89,95,66,65,83,69,32,105,115,32,109,105,115,115,105,110,103,46,10,89,111,117,32,99,97,110,32,103,101,110,101,114,97,116,101,32,111,110,101,32,98,121,32,99,97,108,108,105,110,103,58,32,109,105,120,32,112,104,120,46,103,101,110,46,115,101,99,114,101,116,10>>},[{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,685},{error_info,#{module=>'Elixir.Exception'}}]},{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,446}]},{erl_eval,exprs,5,[{file,"erl_eval.erl"},{line,123}]},{elixir,recur_eval,3,[{file,"src/elixir.erl"},{line,296}]},{elixir,eval_forms,3,[{file,"src/elixir.erl"},{line,274}]},{'Elixir.Code',validated_eval_string,3,[{file,"lib/code.ex"},{line,404}]},{'Elixir.Config','__eval__!',3,[{file,"lib/config.ex"},{line,260}]},{'Elixir.Config.Reader','read!',2,[{file,"lib/config/reader.ex"},{line,92}]}]}}

2022-06-24T01:51:39.895 app[3fdb11b8] fra [info] init terminating in do_boot ({,[{erl_eval,do_apply,6,[{_},{_},{_}]},{erl_eval,expr,5,[{_},{_}]},{erl_eval,exprs,5,[{_},{_}]},{elixir,recur_eval,3,[{_},{_}]},{elixir,eval_forms,3,[{_},{_}]},{Elixir.Code,validated_eval_string,3,[{_},{_}]},{Elixir.Config,__eval__!,3,[{_},{_}]},{Elixir.Config.Reader,read!,2,[{_},{_}]}]})

2022-06-24T01:51:40.053 app[3fdb11b8] fra [info] Crash dump is being written to: erl_crash.dump...done

2022-06-24T01:51:40.310 app[3fdb11b8] fra [info] Rein child exited normally with code: 1

2022-06-24T01:51:40.311 app[3fdb11b8] fra [info] Seaped child process with pid: 570 and signal: SIGUSR1, core dumped? false

2022-06-24T01:51:40.312 app[3fdb11b8] fra [info] Starting clean up.

2022-06-24T01:51:43.392 runner[74d3a551] fra [info] Starting instance

2022-06-24T01:51:44.027 runner[74d3a551] fra [info] Configuring virtual machine

2022-06-24T01:51:44.034 runner[74d3a551] fra [info] Pulling container image

2022-06-24T01:51:44.636 runner[74d3a551] fra [info] Unpacking image

2022-06-24T01:51:44.644 runner[74d3a551] fra [info] Preparing kernel init

2022-06-24T01:51:46.300 runner[74d3a551] fra [info] Configuring firecracker

2022-06-24T01:51:46.538 runner[74d3a551] fra [info] Starting virtual machine

2022-06-24T01:51:46.839 app[74d3a551] fra [info] Starting init (commit: e21acb3)...

2022-06-24T01:51:46.861 app[74d3a551] fra [info] Preparing to run: `bin/dert_gg_web start` as nobody

2022-06-24T01:51:46.872 app[74d3a551] fra [info] 2022/06/24 01:51:46 listening on [fdaa:0:6e5f:a7b:67:74d3:a551:2]:22 (DNS: [fdaa::3]:53)

2022-06-24T01:51:47.869 app[74d3a551] fra [info] Reaped child process with pid: 549, exit code: 0

2022-06-24T01:51:50.787 app[74d3a551] fra [info] 01:51:50.787 [info] Running DertGGWeb.Endpoint with cowboy 2.9.0 at :::4000 (http)

2022-06-24T01:51:50.791 app[74d3a551] fra [info] 01:51:50.790 [info] Access DertGGWeb.Endpoint at http://example.com

2022-06-24T01:51:50.874 app[74d3a551] fra [info] Reaped child process with pid: 570 and signal: SIGUSR1, core dumped? false

2022-06-24T01:51:54.343 app[74d3a551] fra [info] 01:51:54.343 [info] tzdata release in place is from a file last modified Fri, 22 Oct 2021 02:20:47 GMT. Release file on server was last modified Wed, 16 Mar 2022 13:36:02 GMT.

2022-06-24T01:51:55.988 app[74d3a551] fra [info] 01:51:55.987 [info] Tzdata has updated the release from 2021e to 2022a

2022-06-24T01:52:22.872 runner[74d3a551] fra [info] Shutting down virtual machine

2022-06-24T01:52:23.199 app[74d3a551] fra [info] Sending signal SIGINT to main child process w/ PID 515

2022-06-24T01:52:23.200 app[74d3a551] fra [info] BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo

2022-06-24T01:52:23.200 app[74d3a551] fra [info] (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution

2022-06-24T01:52:24.202 app[74d3a551] fra [info] Main child exited normally with code: 0

2022-06-24T01:52:24.203 app[74d3a551] fra [info] Reaped child process with pid: 572 and signal: SIGUSR1, core dumped? false

2022-06-24T01:52:24.203 app[74d3a551] fra [info] Starting clean up.

2022-06-24T01:52:25.987 runner[be6e65fd] fra [info] Starting instance

2022-06-24T01:52:26.545 runner[be6e65fd] fra [info] Configuring virtual machine

2022-06-24T01:52:26.551 runner[be6e65fd] fra [info] Pulling container image

2022-06-24T01:52:29.365 runner[be6e65fd] fra [info] Unpacking image

2022-06-24T01:52:30.974 runner[be6e65fd] fra [info] Preparing kernel init

2022-06-24T01:52:33.317 runner[be6e65fd] fra [info] Configuring firecracker

2022-06-24T01:52:33.428 runner[be6e65fd] fra [info] Starting virtual machine

2022-06-24T01:52:33.694 app[be6e65fd] fra [info] Starting init (commit: e21acb3)...

2022-06-24T01:52:33.713 app[be6e65fd] fra [info] Preparing to run: `bin/dert_gg_web start` as nobody

2022-06-24T01:52:33.723 app[be6e65fd] fra [info] 2022/06/24 01:52:33 listening on [fdaa:0:6e5f:a7b:67:be6e:65fd:2]:22 (DNS: [fdaa::3]:53)

2022-06-24T01:52:34.720 app[be6e65fd] fra [info] Reaped child process with pid: 549, exit code: 0

2022-06-24T01:52:37.292 app[be6e65fd] fra [info] 01:52:37.292 [info] Running DertGGWeb.Endpoint with cowboy 2.9.0 at :::4000 (http)

2022-06-24T01:52:37.294 app[be6e65fd] fra [info] 01:52:37.294 [info] Access DertGGWeb.Endpoint at http://example.com

2022-06-24T01:52:37.725 app[be6e65fd] fra [info] Reaped child process with pid: 570 and signal: SIGUSR1, core dumped? false

2022-06-24T01:52:40.853 app[be6e65fd] fra [info] 01:52:40.853 [info] tzdata release in place is from a file last modified Fri, 22 Oct 2021 02:20:47 GMT. Release file on server was last modified Wed, 16 Mar 2022 13:36:02 GMT.

2022-06-24T01:52:42.532 app[be6e65fd] fra [info] 01:52:42.530 [info] Tzdata has updated the release from 2021e to 2022a

Dockerfile

FROM elixir:1.13.4-alpine AS build

ARG SENTRY_DSN

# install build dependencies
RUN apk add --no-cache build-base npm git

# prepare build dir
WORKDIR /app

# install hex + rebar
RUN mix local.hex --force && \
    mix local.rebar --force

# set build ENV
ENV MIX_ENV=prod

# copy umbrella apps
COPY apps/dert_gg apps/dert_gg
COPY apps/dert_gg_web/ apps/dert_gg_web/

# install mix dependencies
COPY mix.exs mix.lock ./
COPY config config
RUN mix do deps.get --only prod, deps.compile

RUN mix phx.digest

RUN mix do compile, release

# build assets
# COPY apps/dert_gg_web/assets/package.json apps/dert_gg_web/assets/package-lock.json ./apps/dert_gg_web/assets/

# COPY apps/dert_gg_web/priv apps/dert_gg_web/assets apps/dert_gg_web/assets/
# RUN npm --prefix ./apps/dert_gg_web/assets ci --progress=false --no-audit --loglevel=error
# RUN npm run --prefix ./apps/dert_gg_web/assets deploy
# RUN mix phx.digest

# # compile and build release
# COPY . .
# RUN mix do compile, release

# # prepare release image
FROM alpine:3 AS app

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

WORKDIR /app

RUN chown nobody:nobody /app

USER nobody:nobody

COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/dert_gg_web ./

ENV HOME=/app

CMD ["bin/dert_gg_web", "start"]

Fly.toml

# fly.toml file generated for wild-fog-4280 on 2022-06-24T03:20:49+02:00

app = "wild-fog-4280"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  dockerfile = "./Dockerfile"
  build-target = "app"

[env]

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

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

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

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

Secrets

╰─$ fly secrets list
Update available 0.0.332 -> v0.0.335.
Run "fly version update" to upgrade.
NAME            DIGEST                           DATE
DATABASE_URL    112634846a9c0ea63229ffd31795d364 41m25s ago
SECRET_KEY_BASE 90f400390e3e1c14462683d9299173c9 37m18s ago
SENTRY_DSN      01f6ad7ecdd209e8c8cb11fb5e18d967 11m19s ago

What does your config/runtime.exs look like? Do you have a section like:

  secret_key_base =
    System.get_env("SECRET_KEY_BASE") ||
      System.get_env("secret_key_base") ||
      raise """
      environment variable SECRET_KEY_BASE is missing.
      You can generate one by calling: mix phx.gen.secret
      """

If you’re trying to read that env var in a compiled file, it’s being baked in during the docker build and then the actual env var is ignored at runtime. That’s what runtime.exs is for!

Yes, I have the exact same thing in my runtime.exs.

If you’re trying to read that env var in a compiled file, it’s being baked in during the docker build and then the actual env var is ignored at runtime.

Sorry, I didn’t really get what you meant by this, especially how it gets ignored at runtime, but I am not reading that env var anywhere else in code.

On Elixir the files on the config named dev.exs, prod.exs, test.exs and config.exs will only have available environment variables that are exposed to the Docker build. Fly secrets do not get exposed there.

But runtime.exs is an exception. Rather than compile-time, this file works at runtime meaning your server is starting up and it already has access to the Fly secrets.

What @ryansch was trying to ask you was ‘Where do you read SECRET_KEY_BASE?’. If it’s being done in runtime.exs it’s on the right place but if it’s on another file under config/ folder that’s where the issue might be.

1 Like

Would you be comfortable posting the entirety of your runtime.exs here?

1 Like

Also here’s how we’re building our elixir release for fly:
(umbrella apps names changed)

# prepare build dir
WORKDIR /app

# install hex + rebar
RUN mix local.hex --force && \
    mix local.rebar --force

# set build ENV
ENV MIX_ENV="prod"

# install mix dependencies
COPY mix.exs mix.lock ./
COPY apps/app_1/mix.exs apps/app_1/mix.exs
COPY apps/app_2/mix.exs apps/app_2/mix.exs
COPY apps/app_web/mix.exs apps/app_web/mix.exs
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 apps/app_web/priv apps/app_web/priv

COPY apps/app_1/lib apps/app_1/lib
COPY apps/app_2/lib apps/app_2/lib
COPY apps/app_web/lib apps/app_web/lib

COPY apps/app_web/assets apps/app_web/assets

# compile assets
RUN mix do \
  assets.install, \
  assets.deploy

# Compile the release
RUN mix compile

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

COPY rel rel
RUN mix release
1 Like

Sure! There’s not much there anyway.

import Config

# config/runtime.exs is executed for all environments, including
# during releases. It is executed after compilation and before the
# system starts, so it is typically used to load production configuration
# and secrets from environment variables or elsewhere. Do not define
# any compile-time configuration in here, as it won't be applied.
# The block below contains prod specific runtime configuration.
if config_env() == :prod do
  database_url =
    System.get_env("DATABASE_URL") ||
      raise """
      environment variable DATABASE_URL is missing.
      For example: ecto://USER:PASS@HOST/DATABASE
      """

  # maybe_ipv6 = if System.get_env("ECTO_IPV6"), do: [:inet6], else: []

  config :dert_gg, DertGG.Repo,
    ssl: false,
    url: database_url,
    pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
    socket_options: [:inet6]

  # The secret key base is used to sign/encrypt cookies and other secrets.
  # A default value is used in config/dev.exs and config/test.exs but you
  # want to use a different value for prod and you most likely don't want
  # to check this value into version control, so we use an environment
  # variable instead.
  secret_key_base =
    System.get_env("SECRET_KEY_BASE") ||
      raise """
      environment variable SECRET_KEY_BASE is missing.
      You can generate one by calling: mix phx.gen.secret
      """

  config :dert_gg_web, DertGGWeb.Endpoint,
    http: [
      # Enable IPv6 and bind on all interfaces.
      # Set it to  {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
      ip: {0, 0, 0, 0, 0, 0, 0, 0},
      port: String.to_integer(System.get_env("PORT") || "4000")
    ],
    secret_key_base: secret_key_base,
    server: true

  # ## Using releases
  #
  # If you are doing OTP releases, you need to instruct Phoenix
  # to start each relevant endpoint:
  #
  #     config :foobar_web, FoobarWeb.Endpoint, server: true
  #
  # Then you can assemble a release by calling `mix release`.
  # See `mix help release` for more information.

  # ## Configuring the mailer
  #
  # In production you need to configure the mailer to use a different adapter.
  # Also, you may need to configure the Swoosh API client of your choice if you
  # are not using SMTP. Here is an example of the configuration:
  #
  #     config :foobar, Foobar.Mailer,
  #       adapter: Swoosh.Adapters.Mailgun,
  #       api_key: System.get_env("MAILGUN_API_KEY"),
  #       domain: System.get_env("MAILGUN_DOMAIN")
  #
  # For this example you need include a HTTP client required by Swoosh API client.
  # Swoosh supports Hackney and Finch out of the box:
  #
  #     config :swoosh, :api_client, Swoosh.ApiClient.Hackney
  #
  # See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
end

Also here’s how we’re building our elixir release for fly:
(umbrella apps names changed)

Thanks for correcting my Dockerfile :bowing_man: , I don’t have much experience with Docker and I thought the default one didn’t really help me deploy my Elixir umbrella and someone had suggested to use a Dockerfile hence I tried to create it.

I can’t try that Dockerfile now but I’ll definitely try in some free time.

I don’t see any issues with your runtime.exs as written.

Sorry, I just saw this, but yeah as I’ve also shared the files. I am not accessing that env var anywhere except runtime.exs.

I think your issue is not the secret anymore, you might need to change your internal port to 4000.

Health checks might not be able to find anything running on port 8080 and just shutdown.

Can you change from 8080 to 4000 on your fly.toml and see how it goes?

1 Like

I think there’s some progress but this time I got a problem when running the release command. :sweat_smile:

Error

 2022-06-24T21:32:52.635 app[0864a7c5] fra [info] Preparing to run: `eval DertGGWeb.Release.migrate()` as nobody

2022-06-24T21:32:52.637 app[0864a7c5] fra [info] Error: UnhandledIoError(Os { code: 2, kind: NotFound, message: "No such file or directory" })

2022-06-24T21:32:52.638 app[0864a7c5] fra [info] [ 0.083017] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100

2022-06-24T21:32:52.639 app[0864a7c5] fra [info] [ 0.083795] CPU: 0 PID: 1 Comm: init Not tainted 5.12.2 #1

2022-06-24T21:32:52.639 app[0864a7c5] fra [info] [ 0.084360] Call Trace:

2022-06-24T21:32:52.639 app[0864a7c5] fra [info] [ 0.084629] show_stack+0x52/0x58

2022-06-24T21:32:52.640 app[0864a7c5] fra [info] [ 0.084984] dump_stack+0x6b/0x86

2022-06-24T21:32:52.640 app[0864a7c5] fra [info] [ 0.085333] panic+0xfb/0x2bc

2022-06-24T21:32:52.640 app[0864a7c5] fra [info] [ 0.085646] do_exit.cold+0x60/0xb0

2022-06-24T21:32:52.641 app[0864a7c5] fra [info] [ 0.086011] do_group_exit+0x3b/0xb0

2022-06-24T21:32:52.641 app[0864a7c5] fra [info] [ 0.086387] __x64_sys_exit_group+0x18/0x20

2022-06-24T21:32:52.642 app[0864a7c5] fra [info] [ 0.086820] do_syscall_64+0x38/0x50

2022-06-24T21:32:52.642 app[0864a7c5] fra [info] [ 0.087195] entry_SYSCALL_64_after_hwframe+0x44/0xae

2022-06-24T21:32:52.642 app[0864a7c5] fra [info] [ 0.087720] RIP: 0033:0x6fc665

2022-06-24T21:32:52.644 app[0864a7c5] fra [info] [ 0.088040] Code: eb ef 48 8b 76 28 e9 76 05 00 00 64 48 8b 04 25 00 00 00 00 48 8b b0 b0 00 00 00 e9 af ff ff ff 48 63 ff b8 e7 00 00 00 0f 05 <ba> 3c 00 00 00 48 89 d0 0f 05 eb f9 66 2e 0f 1f 84 00 00 00 00 00

2022-06-24T21:32:52.645 app[0864a7c5] fra [info] [ 0.089951] RSP: 002b:00007ffd7b753bf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7

2022-06-24T21:32:52.646 app[0864a7c5] fra [info] [ 0.090728] RAX: ffffffffffffffda RBX: 00000000005cf020 RCX: 00000000006fc665

2022-06-24T21:32:52.647 app[0864a7c5] fra [info] [ 0.091459] RDX: 00000000009cc500 RSI: 0000000000000000 RDI: 0000000000000001

2022-06-24T21:32:52.647 app[0864a7c5] fra [info] [ 0.092191] RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000000

2022-06-24T21:32:52.648 app[0864a7c5] fra [info] [ 0.092939] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd7b753c58

2022-06-24T21:32:52.649 app[0864a7c5] fra [info] [ 0.093672] R13: 00007ffd7b753c68 R14: 0000000000000000 R15: 0000000000000000

2022-06-24T21:32:52.649 app[0864a7c5] fra [info] [ 0.094431] Kernel Offset: disabled

2022-06-24T21:32:52.650 app[0864a7c5] fra [info] [ 0.094800] Rebooting in 1 seconds.. 

fly.toml

# fly.toml file generated for wild-fog-4280 on 2022-06-24T03:20:49+02:00

app = "hidden-wind-6449"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  dockerfile = "./Dockerfile"
  build-target = "app"


[env]

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 4000
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

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

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

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

[deploy]
  release_command =  "eval DertGGWeb.Release.migrate()"

This time it just says “Migrations already up” even thought they’re not.

 2022-06-24T23:58:48.416 runner[5039ab8a] fra [info] Starting instance

2022-06-24T23:58:48.432 runner[5039ab8a] fra [info] Configuring virtual machine

2022-06-24T23:58:48.433 runner[5039ab8a] fra [info] Pulling container image

2022-06-24T23:58:51.155 runner[5039ab8a] fra [info] Unpacking image

2022-06-24T23:58:51.534 runner[5039ab8a] fra [info] Preparing kernel init

2022-06-24T23:58:51.719 runner[5039ab8a] fra [info] Configuring firecracker

2022-06-24T23:58:51.719 runner[5039ab8a] fra [info] Starting virtual machine

2022-06-24T23:58:51.811 app[5039ab8a] fra [info] [ 0.023744] PCI: Fatal: No config space access function found

2022-06-24T23:58:51.850 app[5039ab8a] fra [info] Starting init (commit: e21acb3)...

2022-06-24T23:58:51.866 app[5039ab8a] fra [info] Setting up swapspace version 1, size = 536866816 bytes

2022-06-24T23:58:51.867 app[5039ab8a] fra [info] UUID=cb671321-8e94-49d1-ac18-d6f65c865704

2022-06-24T23:58:51.868 app[5039ab8a] fra [info] Preparing to run: `/app/bin/migrate` as nobody

2022-06-24T23:58:51.873 app[5039ab8a] fra [info] 2022/06/24 23:58:51 listening on [fdaa:0:6e5f:a7b:b9b8:5039:ab8a:2]:22 (DNS: [fdaa::3]:53)

2022-06-24T23:58:52.870 app[5039ab8a] fra [info] Reaped child process with pid: 586 and signal: SIGUSR1, core dumped? false

2022-06-24T23:58:53.557 app[5039ab8a] fra [info] 23:58:53.554 [info] Migrations already up

2022-06-24T23:58:53.871 app[5039ab8a] fra [info] Main child exited normally with code: 0

2022-06-24T23:58:53.872 app[5039ab8a] fra [info] Reaped child process with pid: 588 and signal: SIGUSR1, core dumped? false

2022-06-24T23:58:53.872 app[5039ab8a] fra [info] Starting clean up.

2022-06-24T23:59:01.236 runner[7f4f5886] fra [info] Starting instance

2022-06-24T23:59:01.253 runner[7f4f5886] fra [info] Configuring virtual machine

2022-06-24T23:59:01.254 runner[7f4f5886] fra [info] Pulling container image

2022-06-24T23:59:01.683 runner[7f4f5886] fra [info] Unpacking image

2022-06-24T23:59:01.688 runner[7f4f5886] fra [info] Preparing kernel init

2022-06-24T23:59:01.909 runner[7f4f5886] fra [info] Configuring firecracker

2022-06-24T23:59:02.012 runner[7f4f5886] fra [info] Starting virtual machine 

Okay this post solved my problem.

I forgot to copy my /priv from the core app and I was only copying it from the web app.
Hence migrations were succesful but there was nothing to migrate.

1 Like