Can't get docker or production deploy to work... Blank log/empty response

Hi, I’m probably missing something very simple but I can’t for the life of me get a simple Phoenix app deployed; either directly on my OS X dev machine or with docker.

Here’s what I did:
Created a very simple Phoenix app from scratch, Ph 1.5.6; elixir 1.11.1, OTP 23.

the app works in dev perfectly with ‘mix phx.server’

I’ve created a docker file, exactly as shown here: https://hexdocs.pm/phoenix/releases.html#containers
Only change replaced ‘my_app’ with my app name. Image builds successfully.

When I build image with docker (either locally or on Google Cloud build) and deploy it to either local docker or on a Ubuntu 18.04 server I get literally nothing: the log file is completely blank.
Browser pointed to port 4000 (Chrome) reports empty response. Nothing (absolutely nothing) in the logfile (not even “listening on port 4000 etc.)”

I’ve tried running in prod locally, by following the commands in the Dockerfile and executing same commands locally; everything completes fine.

then when I run:
SECRET_KEY_BASE=“xxx…” DATABASE_URL=“postgresql://postgres:pw@[IPofPostgres]:5432/testdeploy_prod” _build/prod/rel/testdeploy/bin/testdeploy start

I get the same: absolutely nothing on the terminal (it just hangs) and empty response on port 4000. I can see a beam process was started on the machine.
When I CTRL-C I get:
BREAK: (a)bort (A)bort with dump ©ontinue §roc info (i)nfo
(l)oaded (v)ersion (k)ill (D)b-tables (d)istribution

so looks like it was in the beam, but somewhere it is getting stuck.

it does work with “mix phx.server” instead of “start” but that won’t work in the Docker image.

I have no idea what else to try; I’ve been struggling for a week now and is holding up release.

I tried all the above again with a clean install (absolutely no changes made) and the same!!! (going nuts)
Am I missing something really obvious??

Thanks for any pointers.

did update the host and port in the release config file?

Without looking at any configuration, I am making a fairly broad assumption, but it could be related to the versions of elixir you’re using throughout the build process.

A quick look at the dockerfile your using pulls version elixir 1.9.0 (alpine), whilst your application is built using elixir 1.11.1. If your application is expecting 1.11.1, that might be the first place to start looking?

Thanks @muelthe, I had missed the image versions; updated all to latest alpine versions and was very hopeful that would fix the issue, but no avail. Exactly same issue.

I re-installed phx.new, elixir and created a generic phoenix app from scratch (phoenix 1.5.1); using the dockerfile from the documentation with just the image versions updated to ‘latest’ and STILL the same, hangs on ‘start’ after release.

I have no idea what to do; I don’t want to go back to Rails.

Sounds like maybe you didn’t set server: true?
https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#module-runtime-configuration

4 Likes

@adamzapasnik makes a great suggestion.

I’m far from an expert on this, but - the latest tag will take you to elixir version 1.10.4 (see here for reference: https://hub.docker.com/_/elixir?tab=description) and I believe you are using 1.11.1?

It might help if you could share the configuration, even if it’s for the generic app you mentioned.

@dongennl, wondering if you can post the output of your docker build command here - there are might be some issues that won’t stop the image build but may result into runtime issues.

2 Likes

@adamzapasnik YES, THANK YOU!!! That was it; adding server: true to the Endpoint config fixed it.

(I feel very dumb). An older app that I had had indeed got this set and worked, but I hadn’t spotted the difference.

I do find it odd that this is not set for production config in a newly generated app (as it possibly was before), this might catch a few newbies like me, as I don’t think this is mentioned anywhere in the deployment guides.
Surely it would be better in a freshly generated project to explicitly set it to ‘false’ and put a comment that if you want webserver set it to true? I’ll open a ticket to this effect.

Many thanks ALL for your suggestions, really appreciated!!!

4 Likes

I wholeheartedly agree, this is not the first I see someone struggle with it. Glad it worked out :wink:

2 Likes

It is actually inside the phoenix releases page that you link in your initial post (Deploying with Releases — Phoenix v1.7.10). Search for server: true you should see it.

1 Like

I’ve been burnt by this issue a number of times as well, I know the frustration! :slight_smile: