I've scoured App Engine documentations for an explanation on what is an entry point, and I frankly have hit a wall. Was hoping someone on SO can provide an explanation of what and the purpose of an entry point is.
An entrypoint is a Docker command that is executed when the container starts, allowing you to configure a container that will run as an executable.
For App Engine the entrypoint is specified in the app.yaml
file, the command present in the entrypoint field will be included in the entrypoint of your app's Dockerfile, meaning that it is the one that will tell how the application has to be started when you are deploying it. The entrypoint should start a web server that will listen on the port 8080, which is the port used by App Engine to send requests to the deployed container. App Engine provides the PORT
environment variable for ease of use.
For example:
entrypoint: gunicorn -b :$PORT main:app
With this entrypoint you are telling how you want the app to be started, in this case using gunicorn
, and where do you want it to keep listening.
By default, this gunicorn
command is the entrypoint used by App Engine when you do not explicitly set one in the app.yaml
file.
You always need an entrypoint because all App Engine apps are deployed using Docker containers. Even if you only deploy a file with your code, App Engine will build a Docker container with the parameters set in the app.yaml
, because when you deploy an app using App Engine, internally the process used is a build, where the image is given by App Engine.
Also when you deploy an app with App Engine you will be able to find the related build if you go to the Cloud Build section in your GCP console, where you’ll find all the steps and information for the build of the Docker container where your App Engine is being deployed.
In conclusion, App Engine uses the entrypoint from Docker because internally what App Engine is doing while the deploying is using Cloud Build service to build a container image for your app with the information given in the entrypoint.