Copser

Copser

Context
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")
end

but the same error persists.

Dockerfile

# 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
WORKDIR /tmp
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
WORKDIR otp/
RUN ./configure && make && make install

# Install Elixir
ENV LC_ALL en_US.UTF-8
WORKDIR /tm
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
WORKDIR /app

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

# set build ENV

ENV MIX_ENV=prod
ENV DATABASE_URL=postgresql://other@localhost/otherdb
ENV SECRET_KEY_BASE=12345akshdjkasbdjkh
ENV PORT=8080
EXPOSE 8080

# 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?

Showing Posts 1 to 6

Copser

Copser OP

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.

josevalim

josevalim

Creator of Elixir

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

Copser

Copser OP

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.

Copser

Copser OP

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.

dimitarvp

dimitarvp

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

Copser

Copser OP

haha, thanks @dimitarvp will change it

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews