Reputation: 1202
I'm creating an app and when I run it locally things run fine. However, when I run it inside a docker container, during runtime I get the error:
** (UndefinedFunctionError) function EEx.eval_string/2 is undefined (module EEx is not available)
Do I need to specify :eex
inside the extra_applicatoins:
? If so can someone point me to the documentation for this? I thought Eex came with Elixir.
This is my mix.exs
file:
# mix.exs
def application do
[
mod: {MyApp.Application, []},
extra_applications: [:logger]
]
end
defp deps do
[
{:tzdata, "~> 1.0.3"},
{:bamboo, "~> 1.5"}
]
end
Dockerfile:
FROM elixir:1.10 as build
ENV MIX_ENV=prod
ENV LANG=C.UTF-8
RUN mix local.hex --force && mix local.rebar --force
ARG LOG_LEVEL=info
RUN mkdir /build
WORKDIR /build
COPY . .
RUN mix deps.get && \
mix release --path /release && \
rm -rf /build
WORKDIR /release
ENTRYPOINT ["/release/bin/my_app"]
Upvotes: 1
Views: 397
Reputation: 121000
When building a release, only the elixir core is being packed in (:elixir
application in terms of OTP.)
Neither :eex
, nor :mix
, :iex
, and some other extra libraries are included. Even :ssl
and :crypto
available in local development environment are not included into release by default. The goal is to make it explicit to include anything that might not be needed to avoid bloated releases.
I am not sure it’s explicitly documented somewhere, but you might check for reference Phoenix.MixProject
that also includes :eex
application.
For the same reason, any attempt to call Mix.env/0
(or any other Mix
function) would fail in release in the same way.
Upvotes: 2