![](/img/trans.png)
[英]How to profile Google App Engine python27 runtime (not python)
[英]Unable to find/modify the Dockerfile of a Google App Engine Managed VM that uses a standard runtime (python27)
我想修改使用标准运行时(python27)的Google App Engine管理的VM的Dockerfile。
我要添加一个C ++库,该库需要调用才能实现HTTP请求。 这个库几乎是我对沙盒python27运行时唯一需要的添加。
该文档很清楚地表明这是可能的:
每个标准运行时都使用由SDK提供的默认Dockerfile。 您可以通过向该文件添加新的docker命令来扩展和增强标准运行时。
他们在其他地方说,将在项目目录中生成标准运行时的Dockerfile:
当您使用gcloud基于标准运行时(在本例中为Python27)运行或部署托管VM应用程序时,SDK将使用标准运行时作为基础映像创建最小的Dockerfile。 您将在项目目录中找到此Dockerfile ...
这是我应该根据同一页面修改的内容:
本教程后面的步骤将向您展示如何通过向Dockerfile添加指令来扩展运行时环境的功能。
问题在于,当我在开发服务器上运行应用程序时,我无法在任何地方找到Dockerfile,因此无法对其进行任何更改。
是否有人设法修改Google App Engine的标准运行时Dockerfile? 任何帮助,将不胜感激。
要使用google-api-python-client我有同样的问题,因为我需要pycrypto。 我总是得到错误:
CryptoUnavailableError:没有可用的加密库
为了解决这个问题,我创建了一个实例启动处理程序,用于安装所有需要的库。 很难看,但是可以用。
app.yaml中:
handlers:
- url: /_ah/start
script: start_handler.app
start_handler.py
import webapp2
import logging
import os
class StartHandler(webapp2.RequestHandler):
def execute(self, cmd):
logging.info(os.popen("%s 2>&1" % cmd).read())
def get(self):
if not os.environ.get('SERVER_SOFTWARE','').startswith('Development'):
self.execute("apt-get update")
self.execute("apt-get -y install build-essential libssl-dev libffi-dev python-dev")
self.execute("pip install cryptography")
self.execute("pip install pyopenssl")
app = webapp2.WSGIApplication([
('/_ah/start', StartHandler)
], debug=True)
似乎仅在使用gcloud preview app run
时才生成gcloud preview app run
而不是我正在使用的dev_appserver.py
。
但是,我无法修改Dockerfile并运行自定义托管VM。 但这是一个单独的错误(与--custom_entrypoint
相关)。
糟糕的文档和支持助长了整个局势的噩梦。 对其他正在考虑使用Google App Engine的开发人员的警告。
事实证明,在您的应用程序中扩展Dockerfile不能按照文档( Link )中所声称的那样工作。 实际上,如果存在Dockerfile,则会出现以下错误:
"ERROR: (gcloud.preview.app.deploy) There is a Dockerfile in the current directory, and the runtime field in /[...]/app.yaml is currently set to [runtime: python27]. To use your Dockerfile to build a custom runtime, set the runtime field in [...]/app.yaml to [runtime: custom]. To continue using the [python27] runtime, please omit the Dockerfile from this directory"
我能够使用自定义Dockerfile的唯一方法是使用自定义运行时。
Google有一个非常好的GitHub示例,可以使用自定义Python运行时( 此处 )将Django部署到托管VM。
由于您使用的是自定义运行时,因此您必须自己实施运行状况检查。 但是,如果您需要访问Google API,则Google提供了有关如何在GitHub上进行设置的示例( 此处 )。
要获得实施健康检查或与Google API集成的帮助,您可以按照Google Compute Engine入门系列教程( 此处 )进行操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.