While bazel itself works perfectly with Flask, it seems currently it's impossible to deploy app like Python3 quickstart.
The first issue is requirements.txt is not symlinked into bazel-build/path/to/app/app.deploy.runfiles/project (where app.yaml is located). Probably, the issue could be overcome if flask is bundled into external dependency, but gunicorn (or other wsgi server) should be declared somehow.
I manually added symlink to /path/to/app/requirements.txt into bazel-build/path/to/app/app.deploy.runfiles/project and after bazel run //path/to/app:app.deploy it worked, gunicorn dependency was resolved.
The second issue is related to loading main module.
Tried several ways to specify entrypoint in app.yaml:
entrypoint: gunicorn -b :$PORT main:app
This caused the following stacktrace:
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
mod = importlib.import_module(module)
File "/opt/python3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'main'
And
entrypoint: gunicorn -b :$PORT --chdir /path/to/app main:app
entrypoint: gunicorn -b :$PORT path.to.app.main:app
produced:
Traceback (most recent call last):
File "/opt/python3.8/lib/python3.8/pkgutil.py", line 493, in find_loader
spec = importlib.util.find_spec(fullname)
File "/opt/python3.8/lib/python3.8/importlib/util.py", line 94, in find_spec
parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named '/workspace/path/to/app/main'
Any plans on supporting flask in python appengine standard environment?
Thanks.
While bazel itself works perfectly with Flask, it seems currently it's impossible to deploy app like Python3 quickstart.
The first issue is
requirements.txtis not symlinked intobazel-build/path/to/app/app.deploy.runfiles/project(whereapp.yamlis located). Probably, the issue could be overcome ifflaskis bundled into external dependency, butgunicorn(or other wsgi server) should be declared somehow.I manually added symlink to
/path/to/app/requirements.txtintobazel-build/path/to/app/app.deploy.runfiles/projectand afterbazel run //path/to/app:app.deployit worked,gunicorndependency was resolved.The second issue is related to loading
mainmodule.Tried several ways to specify
entrypointinapp.yaml:This caused the following stacktrace:
And
produced:
Any plans on supporting flask in python appengine standard environment?
Thanks.