EleMenk

EleMenk

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: alpine-elixir-phoenix/Dockerfile at master · bitwalker/alpine-elixir-phoenix · GitHub

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?

Showing Posts 1 to 5

iboard

iboard

I have created a docker image in order to deploy my Phoenix app to AWS. Maybe my documentation can help.

NobbZ

NobbZ

This deletes all older content in ., so your downloaded and compiled deps are now deleted.

Better way is to do that line before deps.get and having _build in dockerignore.

EleMenk

EleMenk OP

ADD ./src . is actually fine, if you use ADD ./src/mix.exs ./src/mix.lock ./ before.

Anyways, you brought me on the right track! My problem were the

  volumes:
    - ./src:/opt/app

lines in the docker-compose.yml file. The Dockerfile was fine, but the dependencies got deleted everytime I brought the container up with docker-compose. Now I only have to find a way to be able to edit the code outside of the container, without deleting my dependencies.

Thank you very much for pointing me in the right direction!

iboard

iboard

The link above doesn’t work anymore. Here is the link to the old page https://blog.altendorfer.at/2017/elixir/dev/andi/2017/12/24/deploying-elixirphoenixectopostgres-project-at.html

kieraneglin

kieraneglin

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
dillonoconnor
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
thiagogsr
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews