1

So I am building a Dockerized Django project and I want to deploy it to Heroku, but I am having a lot of issues. My issues are exactly the same as this post: Docker + Django + Postgres Add-on + Heroku

Except I cannot use CMD python3 manage.py runserver 0.0.0.0:$PORT since I receive an invalid port pair error.

I'm just running

heroku container:push web
heroku container:release web
heroku open

After going to the site it stays loading until it says an error occurred. My log shows the following:

 System check identified no issues (0 silenced).
2019-05-03T11:38:47.708761+00:00 app[web.1]: May 03, 2019 - 11:38:47
2019-05-03T11:38:47.709011+00:00 app[web.1]: Django version 2.2.1, using settings 'loan_app.settings.heroku'
2019-05-03T11:38:47.709012+00:00 app[web.1]: Starting development server at http://0.0.0.0:8000/
2019-05-03T11:38:47.709014+00:00 app[web.1]: Quit the server with CONTROL-C.
2019-05-03T11:38:55.505334+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=albmej-loan-application.herokuapp.com request_id=9037f839-8421-46f2-943a-599ec3cc6cb6 fwd="129.161.215.240" dyno= connect= service= status=503 bytes= protocol=https
2019-05-03T11:39:45.091840+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-03T11:39:45.012262+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-05-03T11:39:45.012440+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-05-03T11:39:45.082756+00:00 heroku[web.1]: Process exited with status 137

The app works locally through a virtual environment and using Docker but just not on Heroku. Not sure what else to try. You can find my code at: https://github.com/AlbMej/Online-Loan-Application

Maybe I have some glaring problems in my Dockerfile or docker-compose.yml

  • That linked answer is just wrong. You should **never** be using runserver for production, whether or not you're in a Docker container. You **do** need gunicorn. – Daniel Roseman May 03 '19 at 13:20

2 Answers2

1

The Answer is not correct.

If you use container with Dockerfile, you do not need any Profile.

Just use the $PORT variable to let heroku to determine which port to use.

https://help.heroku.com/PPBPA231/how-do-i-use-the-port-environment-variable-in-container-based-apps

david ye
  • 11
  • 1
0

Quick solution is to change your Procfile to this:

web: python subfolder/manage.py runserver 0.0.0.0:$PORT

That would work, but keep in mind that you are using the development server on production, which is a really bad idea! But if you are just toying around, that's ok.

However, if you're using this as a production app with real data, you should use a real production server. Then your Procfile would look like this:

web: gunicorn yourapp.wsgi --log-file -
Magus
  • 2,905
  • 28
  • 36