← Back to Guides
Profile image for Lavrenti Frobeen

By Lavrenti Frobeen

Published 1st February 2022

Deploying Streamlit on Northflank

Streamlit is an open-source app framework for machine learning and data science projects in Python which allows users to create a web application with a pure Python script. Users can create an interactive web app without spending much time on app development. With Streamlit, creating a dashboard for a machine learning solution has been made incredibly easy.

In this guide, we will show you how to deploy the Streamlit Uber demo on Northflank.

streamlit.png

We started by cloning Streamlit’s Uber demo repo.

In order to deploy the demo on Northflank we had to add some required files.

  • For deployment using a Dockerfile: Dockerfile.
  • For deployment using Buildpack: Procfile and setup.sh

The repo can be found here and it has the following structure:

streamlit/
├─ Dockerfile           (needed for Dockerfile deployment)
├─ Procfile             (needed for Buildpack deployment)
├─ streamlit_app.py
├─ requirements.txt
└─ setup.sh             (needed for Buildpack deployment)

Deploy using Dockerfile

  1. Open the repository containing the Streamlit Uber demo. Click on Use this template to create a copy of this repository under your GitHub account.

  2. Connect your GitHub to your Northflank account. You can find details on how to do so in our documentation.

    git.png

  3. In your project, create a combined service. Under Repository, you will see a list of your repositories from which you can choose the Streamlit repo we just created. Select the branch main and Dockerfile as the build option.

    • For service resources, we recommend at least nf-compute-50 (0.5 vCPU and 1024 MB memory) but you may choose a higher plan for increased performance (lower plans may not be enough for Streamlit to start properly).

    • A combined service handles build and deployment of your code.

    • Port 8080 will automatically be exposed with the HTTP protocol.

      repo.png

  4. Access the deployment via the unique code.run service URL or finish up by linking a custom domain. You will see the example application with a straightforward slider.

Deploy using Buildpack

  1. Open the repository containing the Streamlit Uber demo. Click on Use this template to create a copy of this repository under your Github account.

  2. Connect your Github account to your Northflank account. You can find details on how to do so in our documentation here.

  3. Create a combined service. As source, choose the Streamlit repository you created. Select the branch main and Buildpack as the build option.

    • For service resources, we recommend at least nf-compute-50 (0.5 vCPU and 1024 MB memory) but you may choose a higher plan for increased performance (lower plans may not be enough for Streamlit to start properly).

    buildpack.png

  4. Access the deployment via the unique code.run service URL or finish up by linking a custom domain.

    url.png

The Uber demo application examines how Uber pickups vary over time in New York City's and at its major regional airports. If you want to make changes to the application, you can edit the app.py file. Check out the Streamlit docs for components and other advanced features you can add to your application.

Video

Using Northflank to deploy your Streamlit dashboard or application

Northflank allows you to deploy your code and databases within minutes. Sign up for a Northflank account and create a free project to get started.

  • Connect with your preferred VCS: GitHub, GitLab or Bitbucket
  • Manage build arguments and environment variables using secret groups
  • Scale vertically and horizontally with multiple replicas per service
  • Observe & monitor with real-time metrics & logs
  • Create pipelines and release workflow as you grow

Share this article with your network