β docker-streamlit-app π
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.
β Quick links π
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
β Quick start (recommended) β‘
Build the production runtime image:
Run the packaged container (detached):
Open the app in your browser:
http://localhost:8501
Copy
To stop and remove the container:
make stop
make clean
Copy
β Development / Iteration π οΈ
Mount local app/ into the running container (no image rebuild needed):
Run interactively (attach to logs, removed on exit):
make deploy-devel-interactive
Copy
Enter a shell inside a running container:
β 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 π©Ί
Healthcheck endpoint (inside container): http://localhost:8501/_stcore/healthβ
If port 8501 is busy, either stop the other process or change port mapping in the Makefile.
Inspect container logs:
docker logs docker-streamlit-app
Copy
If dependencies change, rebuild the image:
For UI-only edits, prefer make deploy-devel to avoid rebuilds.
β License π
MIT β see LICENSEβ