GCP App Engine integration

I’ve stumbled on a few different tutorials on deploying Streamlit to GCP App Engine. One common theme is that the App must be deployed in the flexible (not standard) environment, with a Dockerfile. A couple questions:

  1. Why is a container necessary?
  2. Is there an official Streamlit tutorial for launching the “hello world” streamlit app on App Engine?

Hi @j_buddy13, welcome to the Streamlit community!

From my reading of the comparison between the two GCP environments, it looks like the flexible environment is needed because Streamlit uses websockets.

I’m not sure a container is actually required, but that it gives you more flexibility. It seems like only Python 3.6 is available in the flexible environment and so if that’s okay with you, you might be able to get away without using Docker.

There isn’t. We’ve put together the Streamlit Deployment Wiki to try and surface the best examples from the community. But with the number of different services where you could deploy a Streamlit app, it would be difficult for us as a company with the current level of staffing to provide detailed instructions for every environment.

Best,
Randy

it’s easy, but not recommend for stable envs. App Engine spins up a virtual docker host and automatically deploy your Docker container to this env.

In general, the Dockerfile is always named Dockerfile and is placed in the same directory as the corresponding
app.yaml, alternatively you can assign an image URL.

So the only your app code the Docker file, which declares the stack, and an app.yaml is required to trigger a full stack deployment.

Note: Streamlit use WebSockets to create a persistent connection from a client. The open connection allows two-way data exchange between the client and the server at any time, resulting in lower latency and better use of resources.

The App Engine front end forwards incoming requests to the appropriate module on port 8080.
You must ensure that your application code monitors port 8080.


# minimum config in order to use Docker

runtime: custom

env: flex

Deploy: gcloud app deploy ycs-appengine.yaml

1 Like

Hi, I recently tried Streamlit deployment to App Engine and wrote an article.
Let me link it here though this topic is already resolved as it has some additional info not written in this thread:

I think it answers all the questions here and also contains some more tips.


Here is a summary. Please read the article for the details.

the App must be deployed in the flexible (not standard) environment, with a Dockerfile

  1. Why is a container necessary?

As Randy (@randyzwitch ) answered, the flexible environment is necessary for WebSockets.
And the flexible environment is container-based, so “container is necessary” in that sense.
However, a custom runtime with original Dockerfile is not necessary. You can use pre-defined Python3 runtime.

Is there an official Streamlit tutorial for launching the “hello world” streamlit app on App Engine?

The article contains a small but complete example though it’s unofficial.