我的 python 应用程序作为本地 docker 容器运行良好,但是当尝试在 heroku 上部署时,我收到此错误:
错误 R10(启动超时)-> Web 进程未能在启动后 60 秒内绑定(bind)到 $PORT
if __name__ == '__main__':
from os import environ
app.run(host='0.0.0.0', port=environ.get('PORT', 5000))
我的 docker 文件:FROM python:3
# set a directory for the app
WORKDIR /usr/src/app
# copy all the files to the container
COPY . .
# install dependencies
RUN pip3 install --no-cache-dir -r requirements.txt
# heroku doesn't need this
# EXPOSE 5000
# run the command
CMD ["python3", "app.py"]
我认为这可能与该应用程序对于 dyno=1 来说太大了,并且我必须付费才能增加 dynos?但我不确定..提前致谢!!
最佳答案
该应用程序无法绑定(bind)到 Heroku 端口,与 Dyno 无关。在分配端口之前尝试强制转换为 int 端口
port = int(os.environ.get("PORT", 5000))
关于python - 将带有 docker 的 flask 应用程序部署到 heroku 时出现错误 R10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63970527/