Sign inSign up

lpgonzalez/docker_streamlit_app

By lpgonzalez

β€’Updated 10 months ago

Image
0

926

lpgonzalez/docker_streamlit_app repository overview

⁠docker-streamlit-app πŸš€

Python 3.12 Streamlit Docker License: MIT

A compact, Dockerized Streamlit demo that loads a pre-packed scikit-learn model and serves a prediction UI (Iris dataset). Built for teaching and fast iteration.

⁠Authors

  • Lisardo Prieto GonzΓ‘lez
  • Ricardo Aler Mur
  • Luis Mario GarcΓ­a Lafuente

⁠Table of Contents

⁠What it does βš™οΈ

  • Runs a Streamlit app on port 8501.
  • Loads a serialized "pack" (model + metadata) from app/pack_for_streamlit.joblib via app/myst_v4.py.
  • Presents a small UI to enter features and obtain predicted class + probabilities.
  • App entry: app/myst_v4.py
  • Pack: app/pack_for_streamlit.joblib
  • Requirements: app/requirements.txt
  • Notebook used to create the pack: app/p1_sol_deployment.ipynb
  • Docker config: Dockerfile
  • Helpers: Makefile

⁠Prerequisites βœ…

  • Docker Engine
  • GNU Make (optional but recommended)
  • (Optional for local dev) Python 3.12
  1. Build the production runtime image:
make build-prod
  1. Run the packaged container (detached):
make deploy
  1. Open the app in your browser:
http://localhost:8501

To stop and remove the container:

make stop
make clean

⁠Development / Iteration πŸ› οΈ

  • Mount local app/ into the running container (no image rebuild needed):
make deploy-devel
  • Run interactively (attach to logs, removed on exit):
make deploy-devel-interactive
  • Enter a shell inside a running container:
make bash

⁠Makefile targets (summary) πŸ“¦

  • make build-prod β€” Build the production/runtime image (multi-stage Dockerfile).
  • make deploy β€” Run packaged container (detached).
  • make deploy-devel β€” Run container with local app/ mounted for fast dev.
  • make deploy-devel-interactive β€” Run container interactively (attach to stdout/stderr).
  • make stop β€” Stop the running container.
  • make clean β€” Stop and remove the container.
  • make build-prod-all β€” Alias to build-prod (also tags :latest).
  • make push-to-repo β€” Push images to a registry (if tagged).
  • make save-image / load-image β€” Save/load tarball of the image.

⁠Files of interest πŸ“

  • app/myst_v4.py β€” Streamlit entrypoint (loads the joblib pack).
  • app/pack_for_streamlit.joblib β€” Pre-built model + metadata.
  • app/requirements.txt β€” Python deps installed during build.
  • Dockerfile β€” Multi-stage build (builder + runtime).
  • Makefile β€” Convenience tasks to build, run and debug.

⁠Tips & Troubleshooting 🩺

docker logs docker-streamlit-app
  • If dependencies change, rebuild the image:
make build-prod
  • For UI-only edits, prefer make deploy-devel to avoid rebuilds.

⁠License πŸ“œ

MIT β€” see LICENSE⁠

Tag summary

Content type

Image

Digest

sha256:6c9137529…

Size

221.9 MB

Last updated

10 months ago

docker pull lpgonzalez/docker_streamlit_app