This repo contains a Streamlit application for working with OpenPrescribing data.
It is deployed at streamlit.openprescribing.net.
Use uv to create the environment and install
dependencies:
uv syncBy 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.
uv run streamlit run hello.py(or just run)
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.
Build the image and run a smoke test with:
just docker-build
just docker-smokeRun the app from Docker with:
just docker-runDeploys 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.
There is an A record for streamlit.openprescribing.net pointing to 139.59.173.124, dokku5's IP address.
To deploy, the repository needs access to the DOKKU5_DEPLOY_SSH_KEY organisation secret.
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