【发布时间】:2019-09-21 23:26:24
【问题描述】:
所以我正在构建一个 Dockerized Django 项目,我想将它部署到 Heroku,但我遇到了很多问题。我的问题与这篇文章完全相同: Docker + Django + Postgres Add-on + Heroku
除了我不能使用 CMD python3 manage.py runserver 0.0.0.0:$PORT 因为我收到一个无效的端口对错误。
我只是在跑步
heroku container:push web
heroku container:release web
heroku open
访问该站点后,它会一直加载,直到它说发生了错误。我的日志显示如下:
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
该应用程序通过虚拟环境在本地运行并使用 Docker,但不是在 Heroku 上。不知道还有什么可以尝试的。您可以在以下位置找到我的代码:https://github.com/AlbMej/Online-Loan-Application
也许我的 Dockerfile 或 docker-compose.yml 中有一些明显的问题
【问题讨论】:
-
那个链接的答案是错误的。您应该永远将 runserver 用于生产,无论您是否在 Docker 容器中。你确实需要 gunicorn。
标签: django docker heroku docker-compose dockerfile