martins
Mix test runs locally, but not in Docker container
Hi,
I’m able to run my test from my terminal, but if I’m not able to run the tests from within a container.
I get this error when I run docker compose up:
test-1 | Compiling 50 files (.ex)
test-1 | Generated easy_solutions app
test-1 | ** (exit) exited in: GenServer.call(ExUnit.Server, :modules_loaded, :infinity)
test-1 | ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
test-1 | (elixir 1.14.0) lib/gen_server.ex:1027: GenServer.call/3
test-1 | (ex_unit 1.14.0) lib/ex_unit.ex:376: ExUnit.run/1
test-1 | (mix 1.14.0) lib/mix/compilers/test.ex:42: Mix.Compilers.Test.require_and_run/4
test-1 | (mix 1.14.0) lib/mix/tasks/test.ex:543: Mix.Tasks.Test.do_run/3
test-1 | (mix 1.14.0) lib/mix/task.ex:421: anonymous fn/3 in Mix.Task.run_task/4
test-1 | (mix 1.14.0) lib/mix/task.ex:475: Mix.Task.run_alias/6
test-1 | (mix 1.14.0) lib/mix/cli.ex:84: Mix.CLI.run_task/2
I have also tried to replace entrypoint with sleep, so that I can do a docker compose exec test /bin/bash into the container. I can confirm that mix compile works, and I get the same error when I run mix test.
Any suggestions to how I can debug this further?
test.Dockerfile
FROM ubuntu:24.04
ENV MIX_ENV=test
ENV DOCKER_BUILDKIT=1
USER root
RUN apt update
RUN apt install -y erlang-dev elixir erlang-xmerl
RUN apt install -y curl git
RUN useradd -ms /bin/bash appuser
RUN mkdir /app
RUN chown -R appuser /app
USER appuser
COPY . /app
WORKDIR /app
RUN mix local.hex --force
RUN mix local.rebar --force
# install dependencies
COPY mix.exs mix.lock ./
RUN mix deps.get
# compile dependencies
COPY config ./config/
ENTRYPOINT ["mix", "test"]
docker-compose.yaml
version: "3"
services:
test:
environment:
DATABASE_PATH: priv/databases/test.db
SECRET_KEY_BASE: "l7sdfjkhj"
build:
context: .
dockerfile:
test.Dockerfile
volumes:
- ./test_result:/app/test_result
Most Liked
D4no0
martins
Thanks for the suggestion, @jarlah!
Following your advice, I used the Dockerfile generated by mix phx.gen.release --docker.
I added this the the bottom of the Dockerfile:
FROM builder as test
WORKDIR "/app"
ENV MIX_ENV="test"
COPY . .
# install mix dependencies
RUN mix deps.get --only $MIX_ENV
CMD ["mix", "test"]
My docker-compose.yaml looks like this:
version: "3"
services:
test:
environment:
DATABASE_PATH: priv/databases/test.db
SECRET_KEY_BASE: "l7sdfjkhj"
build:
context: .
dockerfile: Dockerfile
Now I can run my tests in a CI/CD pipeline by simply executing
docker compose up test
1
Popular in Questions
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Hi!
In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir?
Searched the docs for ip address and the web, no good results.
Thanks!
New
In templates/appointment/index.html.eex:
<%= for appointment <- @appointments do %>
<tr>
<td><%= appoi...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
Other popular topics
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I’m writing a test for one of the...
New
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









