Closed kminevskiy closed 5 years ago
You say you are deploying a dev release, but using the default configuration - are you building the release locally and then deploying to another machine, or building the release on the same machine it is being run on?
I just ran mix phx.new --no-html --no-webpack --database=postgres
, added distillery
(2.0.14) to deps, changed config/dev.exs
to use the correct username/password for my local pgsql instance, but left the default database name, then built a release with MIX_ENV=dev mix release
and ran it with _build/dev/rel/app/bin/app console
. It fails to connect to the database, but clearly uses the right configuration, and I can dump the config with Application.get_all_env/1
and it is correct.
If you are moving a dev release to another machine, that will not work. By default, dev releases are built with dev_mode: true
, which is designed for running releases during development from within _build
. Much of the release is symlinked rather than copied, and so the release will not function correctly or at all if moved.
You either need to set dev_mode: false
, or use a custom env in rel/config.exs
to manage the configuration so that you can build releases for non-prod environments.
If that is not the issue, then I'll need a more complete reproduction case to help troubleshoot, because a newly created app with the exact same parameters you described works correctly, which means there has to be another factor in the mix here.
I am going to close this for now, but feel free to reopen if you put together a repro case for me, and I'll do what I can to help find a solution!
Paul,
Thanks a lot for your detailed response, really appreciate it!
I wanted to play with Distillery first, so I decided to spin up an Ubuntu VM, build my test releases there and then deploy to the actual server (which is also running Ubuntu).
I'll explain what I want(ed) to achieve: I'd like to have multi-environment (let's say development, staging and production) releases for my Elixir / Phoenix app. Obviously, they will be using different environment configs. I assumed (incorrectly, as it appears) that I can deploy development release just like production. But your explanation makes total sense.
I suppose I'll just add custom envs to my rel/config.exs
. And as far as I understand, they will all have to have dev_mode
set to false
(if I want to deploy them to a different machine), right?
Steps to reproduce
I was following migrations guide from the official hexdocs page. The only difference is that I'm generating a development release.
This is the first time I'm deploying Elixir app using Distillery, so I'm pretty sure I'm missing something obvious. I assumed my app's repo / db config would've been read during release packaging stage from the relevant environment config. Was that a wrong assumption?
Verbose Logs
Description of issue
Custom command will start services and run migrations.
2.0.13
Ubuntu 18.04.02, Kernel 4.15.0-48, Elixir 1.8.2, Erlang/OTP 22
rel/config.exs
, as it is often my first troubleshooting question, and you'll save us both time :)rel/config.exs
contains default configuration.Not sure if I'm missing additional configuration for Ecto or the guide misses these details.
Relevant portion of my
config/dev.exs
: