首页 > 解决方案 > Docker 在 AWS Beanstalk for Python 应用程序上构建超时

问题描述

我有一个在 AWS Beanstalk 上运行的 Python2/Django 应用程序。我使用 Dockerfile 进行部署。firebase-admin==3.2.1在我将依赖项添加到我的requirements.txt. 发生的情况是 Docker 映像构建时间比平时要长,并且 Beanstalk 构建过程开始失败。通过更多分析,我注意到子依赖项需要很长时间才能安装,grpcio==1.31.0. Firebase lib 使用它与 Google API 进行通信。

我试图将命令超时设置增加到 20 分钟或更多,但没有任何改变。EB 部署过程会消耗整个时间间隔并最终失败。我试图进入 EC2 实例本身以找到可以调整的任何有用的东西,但一无所获。

eb-engine.log我相信这是一个示例,它解释了错误部分。

  Stored in directory: /root/.cache/pip/wheels/6f/8e/a7/c5ce8f1742b7d2b9e07cd1064cf201293d157c3c4e1021a74a
  Running setup.py bdist_wheel for psutil: started
  Running setup.py bdist_wheel for psutil: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/39/a0/f5/c4fa280463e29aea07797acb5312358fefb067c1f4f98e11b1
  Running setup.py bdist_wheel for Pyphen: started
  Running setup.py bdist_wheel for Pyphen: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/78/e3/76/42853bf2f7573a72fb5fe377a8406c979a5479ad6930506cde
  Running setup.py bdist_wheel for cairocffi: started
  Running setup.py bdist_wheel for cairocffi: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/3a/2e/92/89e9dcce600a1a78bebe571fdd096669cba354b29c5e1140b9
  Running setup.py bdist_wheel for CairoSVG: started
  Running setup.py bdist_wheel for CairoSVG: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/b0/f0/12/0c41649d33dbc95ce0188188feefc8f90aa877363322fd3ace
  Running setup.py bdist_wheel for gevent: started
  Running setup.py bdist_wheel for gevent: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/66/89/6a/7438b05445edc27023a9d8935801d4e70ed962e02541e57fbd
  Running setup.py bdist_wheel for httplib2: started
  Running setup.py bdist_wheel for httplib2: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/9a/a8/c3/72684de9397a5633e21ba89911174fbc9eb0b1fb9005c6eaf0
  Running setup.py bdist_wheel for grpcio: started
  Running setup.py bdist_wheel for grpcio: still running...
  Running setup.py bdist_wheel for grpcio: still running...
  Running setup.py bdist_wheel for grpcio: still running...

2020/11/05 16:12:14.123278 [ERROR] An error occurred during execution of command [app-deploy] - [Docker Specific Build Application]. Stop running the command. Error: failed to build docker image: Command /bin/sh -c docker build -t aws_beanstalk/staging-app /var/app/staging/ failed with error Command timed out after 300 seconds 

2020/11/05 16:12:14.123302 [INFO] Executing cleanup logic
2020/11/05 16:12:14.131856 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed to build the Docker image. The deployment failed.","timestamp":1604592734,"severity":"ERROR"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1604592734,"severity":"ERROR"}]}]}

2020/11/05 16:12:14.133315 [INFO] Platform Engine finished execution on command: app-deploy

正如您将在前面的示例中注意到的那样,无论Command Timeout设置值如何,Docker 构建过程都会在 300 秒后失败。

Stop running the command. Error: failed to build docker image: Command /bin/sh -c docker build -t aws_beanstalk/staging-app /var/app/staging/ failed with error Command timed out after 300 seconds

标签: python-2.7dockerdockerfileamazon-elastic-beanstalkfirebase-admin

解决方案


推荐阅读