Skip to content

adamatics/containerize-voila-app

Repository files navigation

Containerizing and deploying a Voilá app on AdaLab

This repository contains files that define a Voilá app (access.log, poetry.lock, pyproject.toml, and logs_analytics.ipynb) and a Containerfile (Dockerfile) that specifies the build steps to build a container image for the Voilá app.

In the following sections, we list the steps required to deploy a Voilá app as a containerized stand-alone app on version 1.2.x of AdaLab.

Build the container image

First, open a terminal and make sure that the directory you are in is the folder that the repository was cloned into. Then, from the terminal, build the container image with the below command:

docker build -f Dockerfile -t logs-analytics:1.0 .

The argument -f Dockerfile specifies the file from which to take the docker build instructions. The argument -t logs-analytics:1.0 specifies the name and tag to use for the built container image, and you can specify it as you wish. The only requirement is that a container image with this name does not already exist on your local computer, as this will cause an error, and that the name follows the Open Container Initiative (OCI) naming convention. The build process will look as shown below if you have built this image before. Otherwise, there will be some more steps in which the various components need to be downloaded to the local compute resource.

Add metadata

Once the image building process is complete, you will have the container image available in your Lab on the AdaLab platform. One way to view the container image file is with this command in a terminal, which can be executed from any location:

docker images

The next step is to add metadata to the container image, making it easier to find and manage. This also pushes the container image to a central storage location, making the app available for other users. You do this by heading to the Container Metadata page, as shown below:

Next, you simply wait a few minutes for the publishing process to complete. Click the Refresh button at the top of the Container Metadata page to check whether the publishing process finished. You can also watch the logs to follow along with the build process, or view them after the publishing process finished as shown below:

Deploy app

Once the Container Metadata publishing process finished successfully, an option to deploy the container image as an app will appear in the triple dot menu for the Container Metadata entry. Click this to open a dialog box in which you can fill in the details about the app, such as the name you want it to have and the URL the app will be available at. You can also specify other settings such as resource usage, environment variables, and the startup command. The Strip Prefix checkbox must be unchecked for the containerized Voilá app to deploy successfully, as shown below:

The argument you supplied in the start command in the Dockerfile for --Voila.base_url must match what you specify in the App URL field in the Deploy App dialog box:

So, for the example in this repository where we pass "--Voila.base_url=/apps/logs-analytics/" in the startup command in the Dockerfile, we must specify "logs-analytics" in the App URL field.

Parameters accepted by the app

The logs_analytics.ipynb notebook, which defines the Voilá app, includes code that can parse two parameters given as part of the URL. These two parameters are username and desired-greeting and define the message displayed at the top of the app. They are specified as follows:

https://adalab.adamatics.com/apps/logs-analytics/?desired-greeting=good_morning&username=Your_Name

Where underscores are turned into spaces in the greeting and each word is capitalized. Their default values are "Hello" and "User", respectively.

Troubleshooting

This section describes how to fix various error scenarios.

Running into the 404 page even after fixing bug

Try to clear cookies and site data in the browser for the AdaLab site, and then make sure you log back in before trying again.

Unexpectedly receiving a 404 error

  • Ensure the "Strip Prefix checkbox is unchecked under advanced settings in the "Deply app" dialog.
  • Ensure the Voila.base_url parameter value ends with a "/", e.g. voila basics.ipynb --no-browser --port=8080 --Voila.ip=0.0.0.0 --Voila.base_url=/apps/a-basic-app/
  • Check that the URL you deployed the app to matches the base_url argument you specified in the start command.
  • Check that there is a trailing slash ("/") in the --Voila.base_url argument , as in the example Dockerfile in this repository: "--Voila.base_url=/apps/logs-analytics/".

The Voila spinner appears, but remains at the last cell without rendering the app

Make sure that you specified the Voila.base_url parameter so the app and its contents are located in the expected location.

References

The notebook and sample data were copied from https://github.com/bqplot/bqplot-gallery.git (BSD-3-Clause license as of October 31st 2023).

About

Repository with code to containerize a Voila app.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published