2
votes

I walk through the https://hexdocs.pm/distillery/getting-started.html documentation but can't get a basic Phoenix application up an running. Here's what I do:

mix phoenix.new test_app --no-ecto
cd test_app

Than I update the mix.exs file to include the distillery part:

[...]
defp deps do
  [{:phoenix, "~> 1.2.0-rc"},
   {:phoenix_pubsub, "~> 1.0.0-rc"},
   {:phoenix_html, "~> 2.5"},
   {:phoenix_live_reload, "~> 1.0", only: :dev},
   {:gettext, "~> 0.11"},
   {:cowboy, "~> 1.0"},
   {:distillery, "~> 0.9"}]
end
[...]

Than I run the following commands:

mix deps.get
mix compile
mix release.init
export PORT=4000
./node_modules/brunch/bin/brunch b -p
MIX_ENV=prod mix do phoenix.digest, release --env=prod

That results into this:

05 Sep 17:16:02 - info: compiled 6 files into 2 files, copied 3 in 1.7 sec
Check your digested files at "priv/static"
==> Assembling release..
==> Building release test_app:0.0.1 using environment prod
==> Packaging release..
==> Release successfully built!
    You can run it in one of the following ways:
      Interactive: rel/test_app/bin/test_app console
      Foreground: rel/test_app/bin/test_app foreground
      Daemon: rel/test_app/bin/test_app start

In my understanding I should be able to start a Phoenix application with the command

rel/test_app/bin/test_app foreground

But when I do this I can't access it via the browser at the URL http://localhost:4000

Do I have a wrong setup or do I misunderstand the system? How can I start the new release?

1

1 Answers

4
votes

As mentioned in the Using Distillery With Phoenix page, you need to change some settings in config/prod.exs. After changing the TestApp.Endpoint config to:

config :test_app, TestApp.Endpoint,
  http: [port: {:system, "PORT"}],
  url: [host: "localhost", port: {:system, "PORT"}],
  cache_static_manifest: "priv/static/manifest.json",
  server: true,
  root: ".",
  version: Mix.Project.config[:version]

The following command successfully starts Phoenix on the port previously exported:

rel/test_app/bin/test_app foreground