DEV Community

Cover image for Deploy a Phoenix app with Docker stack

Deploy a Phoenix app with Docker stack

Ivan Iraci on July 10, 2019

The mandatory introductions Hi everybody, this is my very first post on DEV and I want it to be as short as possible, so that anyone cou...
Collapse
 
voger profile image
voger

Using bash, during local migrate, I got this error

ERROR! Config provider Config.Reader failed with:
** (ArgumentError) could not fetch environment variable "SECRET_KEY_BASE" because it is not set
 ...

In bash the line

source .env
_build/prod/rel/demo/bin/demo eval Demo.Release.migrate

must be translated to

set -o allexport; source .env; set +o allexport
_build/prod/rel/demo/bin/demo eval Demo.Release.migrate

I am posting this to save time to someone who might stumble upon this problem.

Collapse
 
khosimorafo profile image
khosimorafo

Thanks for this!

Collapse
 
keedix profile image
Artur Uklejewski

Hello, i can't make it run. I've got the following error when trying to run eval locally:

** (UndefinedFunctionError) function Ecto.Migrator.with_repo/2 is undefined or private

My endpoint.ex and release.ex are updated with you fragments and application name is changed to mine. Postgres is running on port 5432. Have you got any idea why is that ?

Collapse
 
ilsanto profile image
Ivan Iraci

Ecto.Migrator.with_repo/2 was introduced in ecto_sql v3.1.2, maybe you have an older version.

Take a look at your mix.lock.

Collapse
 
filosofisto profile image
Eduardo Ribeiro da Silva

I am using those dependencies:

defp deps do
[
{:phoenix, "~> 1.3.4"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_ecto, "~> 3.2"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.10"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:gettext, "~> 0.11"},
{:plug_cowboy, "~> 1.0"},
{:comeonin, "~> 4.0"},
{:bcrypt_elixir, "~> 1.0"},
{:guardian, "~> 1.0"},
{:number, "~> 1.0.1"}
]
end

And the error is occurring too.
Any idea?

Thread Thread
 
ilsanto profile image
Ivan Iraci
grep ecto_sql mix.lock

ecto_sql version has to be at least 3.1.2, eg:

"ecto_sql": {:hex, :ecto_sql, "3.1.5", ...
                               ^^^^^
Collapse
 
keedix profile image
Artur Uklejewski

Yes that was a problem. Thank you

Collapse
 
chaitanyapi profile image
chaitanyapi

i tried to replicate the above working example to my learning project(which is working fine on localhost including DB activity). however while starting docker-compose, DB container started without any issue, but while the web container is started following error is shown. anyone any idea? please help....

2020-05-26 19:05:51.137 UTC [57] FATAL: database "learn_liveview_dev" does not exist
web_1 | 19:05:51.139 [error] Postgrex.Protocol (#PID<0.2891.0>) failed to connect: ** (Postgrex.Error) FATAL 3D000 (invalid_catalog_name) database "learn_liveview_dev" does not exist

Collapse
 
chaitanyapi profile image
chaitanyapi

Hi Ivan. this is a very nice demonstration of how to get on and start using docker with phoenix app. i followed through the steps and able to create containers without any errors. while starting the app using the docker compose (with dependency on database), the database container started without any issue and is ready to accept connection. however the web container when it ran the entrypoint.sh, it echos the statement that it is still waiting for database to start. i could not understand this. can you please help me out where could i have probably gone wrong or when i can check to find the issue.
Thank you.

Collapse
 
chaitanyapi profile image
chaitanyapi

i think i found the issue with my part... the script is not able to find the env variables. now i have fixed it and this worked.
Thank you.

Collapse
 
perzanko profile image
Kacper Perzankowski

Cool! Thank you!

Collapse
 
gemantzu profile image
George Mantzouranis

Hi, thanks for the tutorial.
How would you run some seeds on this?