I build a Dockerfile
as:
FROM hexpm/elixir:1.15.7-erlang-26.1.2-alpine-3.17.5 AS releaser
RUN apk add --no-cache build-base git python3 curl
WORKDIR /app
RUN mix do local.hex --force, local.rebar --force
COPY config/ ./config/
COPY mix.exs mix.lock ./
COPY apps/liquid_auth/mix.exs ./apps/liquid_auth/
COPY apps/liquid_accounts/mix.exs ./apps/liquid_accounts/
COPY apps/liquid_operations/mix.exs ./apps/liquid_operations/
COPY apps/proxy_web/mix.exs ./apps/proxy_web/
COPY apps/release/mix.exs ./apps/release/
COPY apps/liquid_auth/priv ./apps/liquid_auth/
COPY apps/liquid_accounts/priv ./apps/liquid_accounts/
COPY apps/liquid_operations/priv ./apps/liquid_operations/
ENV MIX_ENV=prod
RUN mix deps.get
RUN mix deps.compile
COPY apps/liquid_auth/lib/ ./apps/liquid_auth/
COPY apps/liquid_accounts/lib/ ./apps/liquid_accounts/
COPY apps/liquid_operations/lib/ ./apps/liquid_operations/
COPY apps/proxy_web/lib/ ./apps/proxy_web/
COPY apps/release/lib/ ./apps/release/
RUN mix compile --force
RUN mix release
FROM alpine:3.17.5 AS app
RUN apk add --no-cache libstdc++ openssl ncurses-libs
EXPOSE 4000
ENV PORT=4000 \
MIX_ENV=prod \
SHELL=/bin/bash \
PHX_SERVER=true
WORKDIR /app
COPY --from=releaser /app/_build/prod/rel/liquid ./
CMD ["bin/liquid", "eval", "Release.migrate", "&&", "exec", "bin/liquid", "start"]
and this is my docker-compose.yml
:
version: "3.8"
services:
pescarte:
build:
context: .
container_name: liquid_dev
ports:
- 4000:4000
depends_on:
- database
env_file:
- .env-sample
volumes:
- .:/src
environment:
MIX_ENV: dev
stdin_open: true
tty: true
database:
image: postgres:14.6
container_name: liquid_database
environment:
- POSTGRES_USER=liquid
- POSTGRES_PASSWORD=liquid
ports:
- 5432:5432
volumes:
- .postgres:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U liquid -d liquid" ]
interval: 5s
timeout: 2s
retries: 1
However when i try to run docker compose up
I get this error:
liquid_dev | ** (UndefinedFunctionError) function Release.migrate/0 is undefined (module Release is not available)
liquid_dev | Release.migrate()
liquid_dev | nofile:1: (file)
liquid_dev | (stdlib 5.1.1) erl_eval.erl:750: :erl_eval.do_apply/7
liquid_dev | (elixir 1.15.7) lib/code.ex:543: Code.validated_eval_string/3
liquid_dev exited with code 1
The full repository with the source code (empty phoenix apps) can be found here
And trying to build with docker build -t liquid-pescarte —no-cache —progress plain .
gives all correct instructions and it compiles down all my umbrella apps, so I didn’t understand why on the runtime its brokes.