Skip to content

docker.md

James Wexler edited this page Oct 29, 2021 · 2 revisions

Running LIT in a Docker container

Users might want to deploy LIT onto servers for public-facing, long-running instances. This is how we host the LIT demos found on https://pair-code.github.io/lit/demos/. Specifically, we deploy containerized LIT instances through Google Cloud's Google Kubernetes Engine (GKE).

The code required to deploy LIT as a containerized web app can be seen by looking at our masked language model demo.

First, let's look at the relevant code in lm_demo.py:

The get_wsgi_app() method is what is invoked by the Dockerfile. It sets the server_type to "external", constructs the LIT Server instance, and returns the result of it's serve() method which is the underlying LitApp WSGI application.

Now, let's explore the Dockerfile:

The Dockerfile installs all necessary dependencies for LIT and builds the front-end code from source. Then it runs gunicorn as the HTTP server, invoking the get_wsgi_app() method from our demo file to get the WSGI app to serve. The options provided to gunicorn for our use-case can be found in gunicorn_config.py.

Then, our container is built and deployed following the basics of the GKE tutorial.