Error (failed_to_start_child) when running ecto in ejabberd production mode inside docker

I added ecto to ejabberd, which worked fine in dev mode (run with iex -S mix), but when ejabberd is compiled and started I get this error:

07:02:09.214 [error] Failed to start module <module-name>: 
{error,
    {shutdown,
        {failed_to_start_child,'Elixir.Ejabberd.Repo',
            {undef,
                [{'Elixir.Ecto.Adapters.Postgres',init,
                     [[{repo,'Elixir.Ejabberd.Repo'},
                       {telemetry_prefix,[ejabberd,repo]},
                       {otp_app,ejabberd},
                       {timeout,15000},
                       {pool_size,10}]],
                     []},
                 {'Elixir.Ecto.Repo.Supervisor',init,1,
                     [{file,"lib/ecto/repo/supervisor.ex"},{line,162}]},
                 {supervisor,init,1,[{file,"supervisor.erl"},{line,295}]},
                 {gen_server,init_it,2,[{file,"gen_server.erl"},{line,374}]},
                 {gen_server,init_it,6,[{file,"gen_server.erl"},{line,342}]},
                 {proc_lib,init_p_do_apply,3,
                     [{file,"proc_lib.erl"},{line,249}]}]}}}}

I’m starting Ejabberd.Repo from custom ejabberd module:

def init(:ok) do
    children = [
    worker(Ejabberd.Repo, [])
   ]

   Supervisor.init(children, strategy: :one_for_one)
end

def start(host, _opts) do
  info("Starting ejabberd module #{__MODULE__} at #{host}")
  :gen_iq_handler.add_iq_handler(:ejabberd_local, host, @namespace, __MODULE__, :on_iq_received)
  Supervisor.start_link(__MODULE__, :ok, [])
end

Ejabberd.Repo is defined in lib/ejabberd/repo.ex:

defmodule Ejabberd.Repo do 
  use Ecto.Repo,           
    otp_app: :ejabberd,
    adapter: Ecto.Adapters.Postgres 
end

connection setup inisde config/config.exs:

config :ejabberd, ecto_repos: [Ejabberd.Repo]

config :ejabberd, Ejabberd.Repo,
  adapter: Ecto.Adapters.Postgres,
  database: "<database-name>",
  username: "<username>",    
  password: "<password>",      
  hostname: "<host>"

application setup from mix.exs:

def application do       
  [mod: {:ejabberd_app, []},
   applications: [:kernel, :stdlib, :sasl, :ssl],
   included_applications: [:lager, :mnesia, :inets, :p1_utils, :cache_tab,
                           :fast_tls, :stringprep, :fast_xml, :xmpp, :mqtree,
                           :stun, :fast_yaml, :esip, :jiffy, :p1_oauth2,
                           :eimp, :base64url, :jose, :pkix, :os_mon, :ecto, :postgrex, :telemetry]
   ++ cond_apps()]       
end

deps from mix.exs:

defp deps do
  [
    {:lager, "~> 3.6.0"},
    {:p1_utils, "~> 1.0"},
    {:fast_xml, "~> 1.1"},
    {:xmpp, "~> 1.3.0"},
    {:cache_tab, "~> 1.0"},
    {:stringprep, "~> 1.0"},
    {:fast_yaml, "~> 1.0"},
    {:fast_tls, "~> 1.1"},
    {:stun, "~> 1.0"},
    {:esip, "~> 1.0"},
    {:p1_mysql, "~> 1.0"},
    {:mqtree, "~> 1.0"},
    {:p1_pgsql, "~> 1.1"},
    {:jiffy, "~> 0.14.7"},
    {:p1_oauth2, "~> 0.6.1"},
    {:distillery, "~> 2.0"},
    {:pkix, "~> 1.0"},
    {:ex_doc, ">= 0.0.0", only: :dev},
    {:eimp, "~> 1.0"},
    {:base64url, "~> 0.0.1"},
    {:jose, "~> 1.8"},
    {:ecto_sql, "~> 3.0"},
    {:postgrex, ">= 0.0.0"}
  ]
  ++ cond_deps()
end

link to official docker repo (https://github.com/processone/docker-ejabberd/tree/master/ecs), only change to docker file is that it is copying files from local version instead cloning it

I guess ejabberd cannot find configuration for ecto, but I don’t know where to put it. I’ve tried adding setup to rel/prod.exs, but it doesn’t make a difference.

Am I missing something? How can I make more sense of this error?

Source: StackOverflow