Hi, I am new to Phoenix and currently trying to get Phoenix into a Docker container.
Somehow, the mix deps.get
and mix deps.compile
commands used in the Dockerfile are executing, but the results seem not to be persisted, as I am getting this when I use the resulting Image with docker-compose
:
-> % docker-compose up
Starting api_db_1 ... done
Starting api_web_1 ...
Starting api_adminer_1 ... done
Attaching to api_db_1, api_web_1, api_adminer_1
db_1 | 2018-01-16 18:09:01.510 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2018-01-16 18:09:01.510 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2018-01-16 18:09:01.519 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2018-01-16 18:09:01.536 UTC [23] LOG: database system was shut down at 2018-01-16 18:05:59 UTC
db_1 | 2018-01-16 18:09:01.542 UTC [1] LOG: database system is ready to accept connections
adminer_1 | PHP 7.2.1 Development Server started at Tue Jan 16 18:09:02 2018
web_1 | Unchecked dependencies for environment dev:
web_1 | * phoenix_live_reload (Hex package)
web_1 | the dependency is not available, run "mix deps.get"
web_1 | * gettext (Hex package)
web_1 | the dependency is not available, run "mix deps.get"
web_1 | * cowboy (Hex package)
web_1 | the dependency is not available, run "mix deps.get"
web_1 | * phoenix_html (Hex package)
web_1 | the dependency is not available, run "mix deps.get"
web_1 | * phoenix_pubsub (Hex package)
web_1 | the dependency is not available, run "mix deps.get"
web_1 | * phoenix (Hex package)
web_1 | the dependency is not available, run "mix deps.get"
web_1 | * postgrex (Hex package)
web_1 | the dependency is not available, run "mix deps.get"
web_1 | * phoenix_ecto (Hex package)
web_1 | the dependency is not available, run "mix deps.get"
web_1 | ** (Mix) Can't continue due to errors on dependencies
api_web_1 exited with code 1
When running docker run --rm -it api_web /bin/bash
to explore the container, the deps container is also missing in the project directory.
When I execute mix deps.get outside of the container and pass the deps into it per docker-volume it works just fine and the deps directory unsurprisingly appears.
I am taking this docker-image as a base-image: https://github.com/bitwalker/alpine-elixir-phoenix/blob/master/Dockerfile
From there, I do this in my own Dockerfile:
FROM bitwalker/alpine-elixir-phoenix:latest
ENV MIX_ENV=dev
ADD src/mix.exs src/mix.lock ./
RUN mix deps.get
RUN mix do deps.compile, compile, phx.digest
ADD ./src .
CMD ["mix", "phx.server"]
finally, the docker-compose file:
db:
image: "postgres:latest"
ports:
- "5432:5432"
environment:
POSTGRES_DB: "api_dev"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
# phoenix web
web:
build: "."
volumes:
- ./src:/opt/app
ports:
- "4000:4000"
links:
- "db:db"
environment:
MIX_ENV: "dev"
# adminer
adminer:
image: adminer
restart: always
ports:
- "84:8080"
links:
- "db:db"
Has somebody experienced similar problems?
Should I rethink putting the dependencies into the container?