Cannot run Google App Engine custom managed VM: --custom-entrypoint must be set error

后端 未结 3 392
囚心锁ツ
囚心锁ツ 2020-12-29 00:28

PROBLEM DESCRIPTION

I am trying to create a custom managed VM for Google App Engine that behaves identically to the standard python27 managed VM pro

3条回答
  •  被撕碎了的回忆
    2020-12-29 00:50

    After trying to get my custom VM working with dev_appserver for the better part of a day, the accepted answer to this post came as a pretty unpleasant surprise. But I figured deploying a dev server couldn't be that much of a hassle because, after all, the VM is a standard Docker image.

    Well there did turn out the be a few issues that prevent a straight deployment from working. I've provided a summary of these issues below as well as how I solved them. I may have missed some incompatibilities between the Docker and App Engine environments (especially with the many aspects of App Engine that my project didn't use) but hopefully it's enough to get people up and running.

    Sources of trouble

    First, I found the python environment run in the Compute Engine VMs to be a bit more lenient than a normal VM environment (e.g. packages like webapp2 are always available). Consequently, deploying to the less forgiving Docker container environment surfaced some latent errors in my project.

    That being said, there are some differences in the environments that necessitate some tweaks even if your project is flawless:

    • Problem: gunicorn (or the server of your choice) must be installed on the Docker container's path.

      • While this may seem obvious, I ran into trouble because I included gunicorn in my project's requirements.txt file. Unfortunately, I was installing all of these dependencies using pip install -t ... which is only able to install source. As a result, there was no gunicorn binary on the image let alone on the PATH.
    • Solution: Explicitly pip install gunicorn


    • Problem: google.appengine.* packages are not available from the App Engine base Docker image nor are they available via pip (AFAICT).
      • This may be a common source of trouble because google.appengine.ext.vendor is the recommended interface for importing third-party libraries into your App Engine app.
    • Solution: I got around this by downloading the entire Google App Engine package hierarchy and placing it on the path of the app.

    How to get the script

    The script to build and deploy the VM docker image to a docker container running locally is available here.

    For an working example, check out my project.

    Let me know if you have a comment, a feature request, or if you write prettier bash than me (I feel I've set the bar comfortably low on that count).

提交回复
热议问题