In my last blog about Serverless Applications with Google App Engine we looked at how to create and deploy simple Flask/Python based application on Google App Engine (GAE). The application is a Serverless Continuous Running Application or ‘SCRA’. A SCRA application runs continuously, has virtually no limit on the code size and programming languages that can be used and you pay only for what you use. Above all, with SCRA applications, you don’t manage servers.
This time we will deploy the application to Google App Engine (GAE) Containers. Lets take a look!
Google App Engine
GAE is a platform for serverless applications that provides development and hosting capabilities to developers. Programs can be developed in most popular programming languages like Python, Go and Java. GAE provides the infrastructure for running web applications at cloud scale. The architecture of GAE is fixed which means that GAE is fit for purpose for certain applications like stateful web applications.
Custom Runtimes and Containers
To support running unsupported runtimes on GAE, like eg. Haskell, Google App Engine provides support for Custom Runtimes in the GAE flexible environment. Custom runtimes are created with a Dockerfile with a base image of choice.
When creating custom runtimes, the application must listen to port
. ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── app.yaml ├── main.py └── requirements.txt.
app.yaml defines the custom runtime and flex environment.
runtime: custom env: flex
THe main difference is the addition of a Dockerfile:
FROM 'python:3.7.1-alpine3.8' ADD requirements.txt / RUN pip install -r requirements.txt ADD main.py / EXPOSE 8080 CMD python main.py
To deploy the example type
make deploy and to invoke the application type
make browse. To remove the application, it must be disabled. A GAE can only be disabled by means of the web console. You have to login to console.cloud.google.com,
choose your project, navigate to GAE, go to settings and disable the application.
The username is
user and the password is
Deploying to App Engine
The GAE deployment proces detects that the application defines a custom runtime. GAE will upload all project files to GAE and automatically build and upload a container to the Google Docker Registry called
appengine which is part of the GCP project.
GAE will then automatically deploy the application and do a rolling update.
The GAE workflow for a custom runtime is the same as for a managed runtime. For a custom runtime a Dockerfile must be added that defines the application runtime and application dependencies. The container should expose port 8080 to get requests forwarded by GAE.