Mix do compile, release Could not read configuration file (config/runtime.exs not found)

I have an app that I deploy to AWS ESC instance, everything was working fine and now after 25+ builds, docker build fails with the message

Generated idms app
* assembling idms-0.1.0 on MIX_ENV=prod
* skipping runtime configuration (config/runtime.exs not found)
** (Mix) Could not read configuration file. It likely has invalid configuration terms such as functions, references, and pids. Please make sure your configuration is made of numbers, atoms, strings, maps, tuples and lists. Reason: {3, :erl_parse, ['syntax error before: ', 'Fun']}
The command '/bin/sh -c mix do compile, release' returned a non-zero code: 1

I’m a bit confused about what’s happening here and how to solve it, I’ve tried then following runtime-configuration documentation and creating releases.exs according to them and I’ve ended up having this inside it

import Config

if config_env() == :prod do
  config :idms,
    host: System.fetch_env!("HOST")
    port: System.fetch_env!("PORT")
    database_url: System.fetch_env!("DATABASE_URL")
    secret_key_base: System.fetch_env!("SECRET_KEY_BASE")
    pool_size: System.fetch_env!("POOL_SIZE")

but the same error persists.


# Building an Phoenix (Elixir) Release targeting Amazon Linux for EC2
# By https://github.com/treygriffith
# Original by the Phoenix team: https://hexdocs.pm/phoenix/releases.html#containers
# Note: Build context should be the application root
# Build Args:
# OTP_VERSION - the OTP version to target, like 23.0
# ELIXIR_VERSION - the Elixir version to target, like 1.10.4
# If you have other environment variables in config/prod.secret.exs, add them as `ARG`s in this file
FROM amazonlinux:2 AS build
# https://gist.github.com/techgaun/335ef6f6abb5a254c66d73ac6b390262
RUN yum -y groupinstall "Development Tools" && 
yum -y install openssl-devel ncurses-devel

# Install Erlang
RUN mkdir -p otp && \
curl -LS "http://erlang.org/download/otp_src_23.0.tar.gz" --output otp.tar.gz && \
tar xfz otp.tar.gz -C otp --strip-components=1
RUN ./configure && make && make install

# Install Elixir
RUN mkdir -p elixir && \
curl -LS "https://github.com/elixir-lang/elixir/archive/v1.11.0.tar.gz" --output elixir.tar.gz && \
tar xfz elixir.tar.gz -C elixir --strip-components=
WORKDIR elixir/
RUN make install -e PATH="${PATH}:/usr/local/bin"

# Install nod
RUN curl -sL https://rpm.nodesource.com/setup_12.x | bash - && \
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
yum install nodejs yarn -y

# prepare build dir

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

# set build ENV

ENV DATABASE_URL=postgresql://other@localhost/otherdb
ENV SECRET_KEY_BASE=12345akshdjkasbdjkh

# install mix dependencies
COPY mix.exs mix.lock ./
COPY config config
RUN mix do deps.get, deps.compile
COPY priv priv
RUN mix phx.digest

# compile and build release
COPY lib lib

# uncomment COPY if rel/ exists
# COPY rel rel
RUN mix do compile, release
CMD mix phx.server

Can someone please help me understand what’s happening, thanks?

Ok just do give some more context to this, I think the problem is Quantum library, so after removing that the docker build finished with no error, so I need to figure out why is this happening.

How are you configuring quantum in your config files? It seems you are using anonymous functions and those are not supported in releases.


Hey @josevalim yes, I need to do something like this,

config :idms, Idms.Scheduler,
  jobs: [
    {"@daily", fn -> Idms.Segments.Actions.Statistics.save_facebook_data_28 end},
    {"@daily", fn -> Idms.Segments.Actions.Statistics.save_facebook_data_daily end},
    {"@daily", fn -> Idms.Segments.Actions.Statistics.save_facebook_data_weakly end},

I have three functions that will fetch Facebook metrics data, but I guess my configuration here is wrong.

I have found solution on how to fix this, thanks @josevalim for the hint, I’ve ended up following @NickTomlin blog on how to setup Quantum for Phoenix app.

1 Like

Language nitpick: it’s not weAkly, it’s weEkly. :wink:

1 Like

haha, thanks @dimitarvp will change it