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

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews