Deploy python3 appengine standard env using bazel and cloud deploy using non containerized artifact?

451 views
Skip to first unread message

Akkul Sahariya

unread,
May 15, 2019, 8:16:45 PM5/15/19
to Google App Engine

Referring to this[

How to deploy to appengine flexible using bazel and google cloud deploy using non containerized artifact?]

I would appreciate if somebody could give me a definitive guide to using bazel to deploy a non containerized python3 standard env steps.

See Deploying artifacts on appengine. I would like to understand how to configure the cloudbuild.yaml to use bazel and run python3 server.


Right now I have changed my project structure to:


.
├── app.yaml
└── package
    ├── app
    │   ├── BUILD
    │   ├── entry.py
    │   ├── forms.py
    │   ├── __init__.py
    │   ├── jinja_custom_filter.py
    │   ├── models.py
    │   ├── __pycache__
    │   ├── static
    │   ├── templates
    │   ├── utils.py
    │   └── views.py
    ├── app.db
    ├── app.yaml
    ├── BUILD
    ├── cloudbuild.yaml
    ├── config.py
    ├── LICENSE
    ├── main.py
    ├── manage.py
    ├── requirements.txt
    └── WORKSPACE
so this structure is different from what I posted on SO.


Here is my main.py

#!flask/bin/python
from app.entry import app
import os
port = int(os.environ.get('PORT', 8081))
print('hello world!', port)

app.run(host='0.0.0.0', debug=True)


Now the error that i get is:


Waiting for new log entries...
2019-05-04 13:44:56 default[20190502t042901]  /env/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.
2019-05-04 13:44:56 default[20190502t042901]    warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.')
2019-05-04 13:44:56 default[20190502t042901]  hello world!
2019-05-04 13:44:56 default[20190502t042901]  [2019-05-04 13:44:56 +0000] [19] [ERROR] Exception in worker process
2019-05-04 13:44:56 default[20190502t042901]  Traceback (most recent call last):    File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker      worker.init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process      self.load_wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi      self.wsgi = self.app.wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi      self.callable = self.load()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load      return self.load_wsgiapp()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp      return util.import_app(self.app_uri)    File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app      __import__(module)    File "/srv/run.py", line 6, in <module>      app.run(host='0.0.0.0', port=os.environ['PORT'], debug=True)    File "/env/lib/python3.7/site-packages/flask/app.py", line 772, in run      run_simple(host, port, self, **options)    File "/env/lib/python3.7/site-packages/werkzeug/serving.py", line 675, in run_simple      s.bind((hostname, port))  TypeError: an integer is required (got type str)
2019-05-04 13:44:56 default[20190502t042901]  [2019-05-04 13:44:56 +0000] [19] [INFO] Worker exiting (pid: 19)
2019-05-04 13:44:56 default[20190502t042901]  [2019-05-04 13:44:56 +0000] [8] [INFO] Shutting down: Master
2019-05-04 13:44:56 default[20190502t042901]  [2019-05-04 13:44:56 +0000] [8] [INFO] Reason: Worker failed to boot.
2019-05-04 13:46:10 default[20190502t041811]  "GET /_ah/start HTTP/1.1" 502
2019-05-04 13:46:11 default[20190502t041811]  [2019-05-04 13:46:11 +0000] [8] [INFO] Starting gunicorn 19.9.0
2019-05-04 13:46:11 default[20190502t041811]  [2019-05-04 13:46:11 +0000] [8] [INFO] Listening at: http://0.0.0.0:8081 (8)
2019-05-04 13:46:11 default[20190502t041811]  [2019-05-04 13:46:11 +0000] [8] [INFO] Using worker: sync
2019-05-04 13:46:11 default[20190502t041811]  [2019-05-04 13:46:11 +0000] [18] [INFO] Booting worker with pid: 18
2019-05-04 13:46:12 default[20190502t041811]  /env/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.
2019-05-04 13:46:12 default[20190502t041811]    warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.')
2019-05-04 13:46:12 default[20190502t041811]  hello world!
2019-05-04 13:46:12 default[20190502t041811]  [2019-05-04 13:46:12 +0000] [18] [ERROR] Exception in worker process
2019-05-04 13:46:12 default[20190502t041811]  Traceback (most recent call last):    File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker      worker.init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process      self.load_wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi      self.wsgi = self.app.wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi      self.callable = self.load()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load      return self.load_wsgiapp()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp      return util.import_app(self.app_uri)    File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app      __import__(module)    File "/srv/run.py", line 5, in <module>      app.run(host='0.0.0.0', port=8080, debug=True)    File "/env/lib/python3.7/site-packages/flask/app.py", line 772, in run      run_simple(host, port, self, **options)    File "/env/lib/python3.7/site-packages/werkzeug/serving.py", line 675, in run_simple      s.bind((hostname, port))  OSError: [Errno 98] Address already in use
2019-05-04 13:46:12 default[20190502t041811]  [2019-05-04 13:46:12 +0000] [18] [INFO] Worker exiting (pid: 18)
2019-05-04 13:46:12 default[20190502t041811]  [2019-05-04 13:46:12 +0000] [8] [INFO] Shutting down: Master
2019-05-04 13:46:12 default[20190502t041811]  [2019-05-04 13:46:12 +0000] [8] [INFO] Reason: Worker failed to boot.
2019-05-04 13:47:35 default[20190504t191438]  "GET / HTTP/1.1" 502
2019-05-04 13:47:37 default[20190504t191438]  [2019-05-04 13:47:37 +0000] [8] [INFO] Starting gunicorn 19.9.0
2019-05-04 13:47:37 default[20190504t191438]  [2019-05-04 13:47:37 +0000] [8] [INFO] Listening at: http://0.0.0.0:8081 (8)
2019-05-04 13:47:37 default[20190504t191438]  [2019-05-04 13:47:37 +0000] [8] [INFO] Using worker: threads
2019-05-04 13:47:37 default[20190504t191438]  [2019-05-04 13:47:37 +0000] [24] [INFO] Booting worker with pid: 24
2019-05-04 13:47:37 default[20190504t191438]  [2019-05-04 13:47:37 +0000] [24] [ERROR] Exception in worker process
2019-05-04 13:47:37 default[20190504t191438]  Traceback (most recent call last):    File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker      worker.init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 104, in init_process      super(ThreadWorker, self).init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process      self.load_wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi      self.wsgi = self.app.wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi      self.callable = self.load()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load      return self.load_wsgiapp()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp      return util.import_app(self.app_uri)    File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app      __import__(module)  ModuleNotFoundError: No module named 'main'
2019-05-04 13:47:37 default[20190504t191438]  [2019-05-04 13:47:37 +0000] [24] [INFO] Worker exiting (pid: 24)
2019-05-04 13:47:37 default[20190504t191438]  [2019-05-04 13:47:37 +0000] [8] [INFO] Shutting down: Master
2019-05-04 13:47:37 default[20190504t191438]  [2019-05-04 13:47:37 +0000] [8] [INFO] Reason: Worker failed to boot.
2019-05-04 13:47:37 default[20190504t191438]  "GET /favicon.ico HTTP/1.1" 500
2019-05-04 13:51:19 default[20190502t042901]  "GET /_ah/start HTTP/1.1" 502
2019-05-04 13:51:20 default[20190502t042901]  [2019-05-04 13:51:20 +0000] [8] [INFO] Starting gunicorn 19.9.0
2019-05-04 13:51:20 default[20190502t042901]  [2019-05-04 13:51:20 +0000] [8] [INFO] Listening at: http://0.0.0.0:8081 (8)
2019-05-04 13:51:20 default[20190502t042901]  [2019-05-04 13:51:20 +0000] [8] [INFO] Using worker: sync
2019-05-04 13:51:20 default[20190502t042901]  [2019-05-04 13:51:20 +0000] [18] [INFO] Booting worker with pid: 18
2019-05-04 13:51:21 default[20190502t042901]  /env/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.
2019-05-04 13:51:21 default[20190502t042901]    warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.')
2019-05-04 13:51:21 default[20190502t042901]  hello world!
2019-05-04 13:51:21 default[20190502t042901]  [2019-05-04 13:51:21 +0000] [18] [ERROR] Exception in worker process
2019-05-04 13:51:21 default[20190502t042901]  Traceback (most recent call last):    File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker      worker.init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process      self.load_wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi      self.wsgi = self.app.wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi      self.callable = self.load()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load      return self.load_wsgiapp()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp      return util.import_app(self.app_uri)    File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app      __import__(module)    File "/srv/run.py", line 6, in <module>      app.run(host='0.0.0.0', port=os.environ['PORT'], debug=True)    File "/env/lib/python3.7/site-packages/flask/app.py", line 772, in run      run_simple(host, port, self, **options)    File "/env/lib/python3.7/site-packages/werkzeug/serving.py", line 675, in run_simple      s.bind((hostname, port))  TypeError: an integer is required (got type str)
2019-05-04 13:51:21 default[20190502t042901]  [2019-05-04 13:51:21 +0000] [18] [INFO] Worker exiting (pid: 18)
2019-05-04 13:51:21 default[20190502t042901]  [2019-05-04 13:51:21 +0000] [8] [INFO] Shutting down: Master
2019-05-04 13:51:21 default[20190502t042901]  [2019-05-04 13:51:21 +0000] [8] [INFO] Reason: Worker failed to boot.
2019-05-04 20:56:18 default[20190505t021600]  "GET / HTTP/1.1" 500
2019-05-04 20:56:19 default[20190505t021600]  /bin/sh: 1: exec: gunicorn: not found
2019-05-04 20:56:21 default[20190505t021600]  "GET /favicon.ico HTTP/1.1" 500
2019-05-04 20:56:21 default[20190505t021600]  /bin/sh: 1: exec: gunicorn: not found
2019-05-04 20:56:24 default[20190505t021600]  "GET / HTTP/1.1" 500
2019-05-04 20:56:24 default[20190505t021600]  /bin/sh: 1: exec: gunicorn: not found
2019-05-04 21:21:41 default[20190505t024917]  "GET / HTTP/1.1" 502
2019-05-04 21:21:43 default[20190505t024917]  [2019-05-04 21:21:43 +0000] [8] [INFO] Starting gunicorn 19.9.0
2019-05-04 21:21:43 default[20190505t024917]  [2019-05-04 21:21:43 +0000] [8] [INFO] Listening at: http://0.0.0.0:8081 (8)
2019-05-04 21:21:43 default[20190505t024917]  [2019-05-04 21:21:43 +0000] [8] [INFO] Using worker: threads
2019-05-04 21:21:44 default[20190505t024917]  [2019-05-04 21:21:44 +0000] [24] [INFO] Booting worker with pid: 24
2019-05-04 21:21:44 default[20190505t024917]  [2019-05-04 21:21:44 +0000] [24] [ERROR] Exception in worker process
2019-05-04 21:21:44 default[20190505t024917]  Traceback (most recent call last):    File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker      worker.init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 104, in init_process      super(ThreadWorker, self).init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process      self.load_wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi      self.wsgi = self.app.wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi      self.callable = self.load()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load      return self.load_wsgiapp()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp      return util.import_app(self.app_uri)    File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app      __import__(module)  ModuleNotFoundError: No module named 'main'
2019-05-04 21:21:44 default[20190505t024917]  [2019-05-04 21:21:44 +0000] [24] [INFO] Worker exiting (pid: 24)
2019-05-04 21:21:44 default[20190505t024917]  [2019-05-04 21:21:44 +0000] [8] [INFO] Shutting down: Master
2019-05-04 21:21:44 default[20190505t024917]  [2019-05-04 21:21:44 +0000] [8] [INFO] Reason: Worker failed to boot.
2019-05-04 21:32:41 default[20190505t030108]  "GET / HTTP/1.1" 502
2019-05-04 21:32:42 default[20190505t030108]  [2019-05-04 21:32:42 +0000] [8] [INFO] Starting gunicorn 19.9.0
2019-05-04 21:32:42 default[20190505t030108]  [2019-05-04 21:32:42 +0000] [8] [INFO] Listening at: http://0.0.0.0:8081 (8)
2019-05-04 21:32:42 default[20190505t030108]  [2019-05-04 21:32:42 +0000] [8] [INFO] Using worker: threads
2019-05-04 21:32:42 default[20190505t030108]  [2019-05-04 21:32:42 +0000] [24] [INFO] Booting worker with pid: 24
2019-05-04 21:32:42 default[20190505t030108]  [2019-05-04 21:32:42 +0000] [24] [ERROR] Exception in worker process
2019-05-04 21:32:42 default[20190505t030108]  Traceback (most recent call last):    File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker      worker.init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 104, in init_process      super(ThreadWorker, self).init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process      self.load_wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi      self.wsgi = self.app.wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi      self.callable = self.load()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load      return self.load_wsgiapp()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp      return util.import_app(self.app_uri)    File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app      __import__(module)  ModuleNotFoundError: No module named 'main'
2019-05-04 21:32:42 default[20190505t030108]  [2019-05-04 21:32:42 +0000] [24] [INFO] Worker exiting (pid: 24)
2019-05-04 21:32:42 default[20190505t030108]  [2019-05-04 21:32:42 +0000] [8] [INFO] Shutting down: Master
2019-05-04 21:32:42 default[20190505t030108]  [2019-05-04 21:32:42 +0000] [8] [INFO] Reason: Worker failed to boot.
2019-05-04 21:47:40 default[20190505t030108]  "GET / HTTP/1.1" 502
2019-05-04 21:47:43 default[20190505t030108]  [2019-05-04 21:47:43 +0000] [8] [INFO] Starting gunicorn 19.9.0
2019-05-04 21:47:43 default[20190505t030108]  [2019-05-04 21:47:43 +0000] [8] [INFO] Listening at: http://0.0.0.0:8081 (8)
2019-05-04 21:47:43 default[20190505t030108]  [2019-05-04 21:47:43 +0000] [8] [INFO] Using worker: threads
2019-05-04 21:47:43 default[20190505t030108]  [2019-05-04 21:47:43 +0000] [23] [INFO] Booting worker with pid: 23
2019-05-04 21:47:43 default[20190505t030108]  [2019-05-04 21:47:43 +0000] [23] [ERROR] Exception in worker process
2019-05-04 21:47:43 default[20190505t030108]  Traceback (most recent call last):    File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker      worker.init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 104, in init_process      super(ThreadWorker, self).init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process      self.load_wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi      self.wsgi = self.app.wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi      self.callable = self.load()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load      return self.load_wsgiapp()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp      return util.import_app(self.app_uri)    File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app      __import__(module)  ModuleNotFoundError: No module named 'main'
2019-05-04 21:47:43 default[20190505t030108]  [2019-05-04 21:47:43 +0000] [23] [INFO] Worker exiting (pid: 23)
2019-05-04 21:47:43 default[20190505t030108]  [2019-05-04 21:47:43 +0000] [8] [INFO] Shutting down: Master
2019-05-04 21:47:43 default[20190505t030108]  [2019-05-04 21:47:43 +0000] [8] [INFO] Reason: Worker failed to boot.
2019-05-11 10:40:50 default[20190505t030108]  "GET / HTTP/1.1" 502
2019-05-11 10:40:53 default[20190505t030108]  [2019-05-11 10:40:53 +0000] [8] [INFO] Starting gunicorn 19.9.0
2019-05-11 10:40:53 default[20190505t030108]  [2019-05-11 10:40:53 +0000] [8] [INFO] Listening at: http://0.0.0.0:8081 (8)
2019-05-11 10:40:53 default[20190505t030108]  [2019-05-11 10:40:53 +0000] [8] [INFO] Using worker: threads
2019-05-11 10:40:53 default[20190505t030108]  [2019-05-11 10:40:53 +0000] [24] [INFO] Booting worker with pid: 24
2019-05-11 10:40:53 default[20190505t030108]  [2019-05-11 10:40:53 +0000] [24] [ERROR] Exception in worker process
2019-05-11 10:40:53 default[20190505t030108]  Traceback (most recent call last):    File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker      worker.init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 104, in init_process      super(ThreadWorker, self).init_process()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process      self.load_wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi      self.wsgi = self.app.wsgi()    File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi      self.callable = self.load()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load      return self.load_wsgiapp()    File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp      return util.import_app(self.app_uri)    File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app      __import__(module)  ModuleNotFoundError: No module named 'main'
2019-05-11 10:40:53 default[20190505t030108]  [2019-05-11 10:40:53 +0000] [24] [INFO] Worker exiting (pid: 24)
2019-05-11 10:40:53 default[20190505t030108]  [2019-05-11 10:40:53 +0000] [8] [INFO] Shutting down: Master
2019-05-11 10:40:53 default[20190505t030108]  [2019-05-11 10:40:53 +0000] [8] [INFO] Reason: Worker failed to boot.
2019-05-11 10:40:54 default[20190505t030108]  "GET /favicon.ico HTTP/1.1" 500
2019-05-11 10:52:41 default[20190511t161834]  "GET / HTTP/1.1" 500
2019-05-11 10:52:42 default[20190511t161834]  /bin/sh: 1: exec: gunicorn: not found
2019-05-11 10:58:19 default[20190511t162632]  "GET / HTTP/1.1" 500
2019-05-11 10:58:20 default[20190511t162632]  /bin/sh: 1: exec: gunicorn: not found
2019-05-12 08:29:41 default[20190512t135308]  "GET / HTTP/1.1" 500
2019-05-12 08:29:41 default[20190512t135308]  /bin/sh: 1: exec: gunicorn: not found
2019-05-12 08:45:55 default[20190512t141217]  "GET / HTTP/1.1" 500
2019-05-12 08:45:55 default[20190512t141217]  /bin/sh: 1: exec: gunicorn: not found



Aref Amiri (Cloud Platform Support)

unread,
May 17, 2019, 5:13:07 PM5/17/19
to Google App Engine

When deploying App GAE Standard, it auto creates the Cloud Build image but cannot be altered or use Bazel. If you intend to use Bazel command in Cloud Build you can follow the instructions here.


Based on the information you've provided, this seems to be running in GAE Flex but the title is GAE Standard. Can you confirm which one you are referring to?


Akkul Sahariya

unread,
May 19, 2019, 11:36:55 AM5/19/19
to Google App Engine
Hi Aref,

So if I understood this correct:

IN CLOUDBUILD.YAML:
steps:
# Build the Docker image and load it into the Docker daemon.
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '--tag=gcr.io/$PROJECT_ID/deploy:latest', '.']
  # The loaded image name is the BUILD target's name, prefixed with bazel/.
- name: 'gcr.io/cloud-builders/bazel'
  args: ['run', 'gcr.io/$PROJECT_ID/deploy:latest']
# Re-tag the image to something in your project's gcr.io repository.
- name: 'gcr.io/cloud-builders/docker'
  args: ['tag', 'gcr.io/$PROJECT_ID/deploy:latest', 'gcr.io/$PROJECT_ID/server']
# Push the image.
images: ['gcr.io/$PROJECT_ID/server']


In WORKSPACE:
load(
   
"@io_bazel_rules_docker//python:image.bzl",
    _py_image_repos
= "repositories",
)

_py_image_repos
()


IN BUILD FILES:
  load("@io_bazel_rules_docker//python:image.bzl", "py3_image")

  REPLACE py_binary
with py3_image(
  name
= "py_image",
  srcs
= ["py_image.py"],
  deps
= [":py_image_library"],
  main
= "py_image.py",
 
# "layers" is just like "deps", but it also moves the dependencies each into
  # their own layer, which can dramatically improve developer cycle time.  For
  # example here, the grpcio layer is ~40MB, but the rest of the app is only
  # ~400KB.  By partitioning things this way, the large grpcio layer remains
  # unchanging and we can reduce the amount of image data we repush by ~99%!
  layers = [
    requirement
("grpcio"),
   
"//examples/hellogrpc/proto:py",
 
],
 
)


And then
sudo gcloud builds submit --config package/cloudbuild.yaml ./package/

 sudo gcloud app deploy app.yaml Enter code here...

Is this the correct way to use bazel and deploy to gae standard?

Thanks.

Akkul Sahariya

unread,
May 19, 2019, 11:36:55 AM5/19/19
to Google App Engine
Another question is, is using bazel using standard gae a best practice or would you suggest otherwise?


On Saturday, May 18, 2019 at 2:43:07 AM UTC+5:30, Aref Amiri (Cloud Platform Support) wrote:

Aref Amiri (Cloud Platform Support)

unread,
May 27, 2019, 5:51:36 PM5/27/19
to Google App Engine
You can follow the instructions provided here to help you with building Java App Engine application or Python App Engine application with Bazel. In addition, for best practices and deploying rules, I'd suggest review this page.

If you need additional assistance with technical question, it is recommended to post your detailed questions to Stackoverflow using the supported Cloud tags, as Google Groups is mainly reserved for general product discussions.

George (Cloud Platform Support)

unread,
May 27, 2019, 5:52:35 PM5/27/19
to Google App Engine
Hello Akkul, 

Right reply to your question depends on details such as correct paths and similar. If you followed the provided example faithfully, you should succeed. 

This discussion group is oriented more towards general opinions, trends, and issues of general nature touching App Engine and Cloud SQL. For coding and programming architecture, as well as using Bazel to deploy a non containerized python3 standard env, you may be better served in dedicated forums such as stackoverflow, where experienced programmers are within reach and ready to help. 
Reply all
Reply to author
Forward
0 new messages