Skip to content

Repository files navigation

openprescribing-streamlit

This repo contains a Streamlit application for working with OpenPrescribing data.

It is deployed at streamlit.openprescribing.net.

Setup

Use uv to create the environment and install dependencies:

uv sync

By default, the app reads prescribing.duckdb and data.sqlite from the data/ directory. To use a different directory, set OPENPRESCRIBING_STREAMLIT_DATA_DIR to the directory containing the databases.

Running the app

uv run streamlit run hello.py

(or just run)

Refreshing materialised views

SQL files in apps/[app-name]/materliased_views/ will be used to generate materialised views in materialised_views.duckdb.

The views will be refreshed on deploy.

To refresh manually, run:

uv run refresh_materialised_views.py

(or just refresh_materialised_views)

This will only refresh views whose SQL has changed.

Docker

Build the image and run a smoke test with:

just docker-build
just docker-smoke

Run the app from Docker with:

just docker-run

Deployment

Deploys are handled by GitHub Actions via deploy.yml. Pushing to main builds the Docker image, pushes it to GitHub Container Registry, and asks Dokku to deploy that image on dokku5.ebmdatalab.net.

Cloudflare setup

There is an A record for streamlit.openprescribing.net pointing to 139.59.173.124, dokku5's IP address.

GitHub setup

To deploy, the repository needs access to the DOKKU5_DEPLOY_SSH_KEY organisation secret.

Dokku setup

The following commands were run to set up the app on dokku5:

dokku apps:create openprescribing-streamlit
dokku domains:add openprescribing-streamlit streamlit.openprescribing.net
dokku letsencrypt:enable openprescribing-streamlit
dokku ports:set openprescribing-streamlit http:80:8501 https:443:8501
dokku storage:mount openprescribing-streamlit /var/lib/dokku/data/storage/openprescribing:/storage
dokku config:set openprescribing-streamlit OPENPRESCRIBING_STREAMLIT_DATA_DIR=/storage

About

A Streamlit application for working with OpenPrescribing data

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages