Once the GCP account is set up (see previously), only a few additional minutes are needed to launch a serverless app from an actual production environment.
The interactive tutorial, if followed, will clone a source repository. Willing to start from scratch with a minimal approach, I cancelled the interactive tutorial to follow the “Quickstart for Python App Engine Standard Environment” tutorial. This cannot be more simple. It consists in the following:
- Install and initialize the “Google Cloud SDK”
- Get the
python-docs-samples/appengine/standard/hello_worldsample code (2 files needed, see below)
- Test the app locally (open http://localhost:8080/)
- Deploy the app
Only 2 Files Needed for a Minimal App
main.py(Python source code)
$ dev_appserver.py app.yaml
INFO 2017-03-20 21:36:53,313 devappserver2.py:764] Skipping SDK update check.
INFO 2017-03-20 21:36:53,361 api_server.py:268] Starting API server at: http://localhost:59317
INFO 2017-03-20 21:36:53,375 dispatcher.py:199] Starting module "default" running at: http://localhost:8080
INFO 2017-03-20 21:36:53,375 admin_server.py:116] Starting admin server at: http://localhost:8000
INFO 2017-03-20 21:39:20,387 module.py:806] default: "GET / HTTP/1.1" 200 13
Deploy to Production
$ gcloud app deployYou are about to deploy the following services:
- majestic-gizmo-162110/default/... (from [...app.yaml])
Deploying to URL: [https://majestic-gizmo-162110.appspot.com]Do you want to continue (Y/n)? YBeginning deployment of service [default]...
File upload done.
Updating service [default]...done.
Deployed service [default] to [https://majestic-gizmo-162110.appspot.com]You can stream logs from the command line by running:
$ gcloud app logs tail -s defaultTo view your application in the web browser run:
$ gcloud app browse
From the moment the app is deployed, the billing status shows estimated costs.
- This is as simple as it can be. Deploying a serverless app from scratch to production is a matter of minutes.
- To avoid using unnecessary resources (and potentially being charged for them), delete the test project (see “Clean up” in the tutorial)
- This was too easy. Let’s develop an app that actually does something…