A Python app that fetches real-time stock prices for the top 10 US-listed companies by market cap. Used to demonstrate progressive container hardening — from a public Docker Hub image to a Chainguard image, and from public PyPI packages to Chainguard Libraries.
app.py fetches prices concurrently from Yahoo Finance and prints a formatted table.
Dependencies (requirements.txt):
aiohttp==3.13.5pillow==12.3.0mistralai==2.4.5
- Docker
- Grype
Each script pulls the base image, builds the app image, then pauses so you can review the build output. Press Enter at the prompt to run the Grype scan.
./build-and-scan-public.shBuilds demo-chainguard-python:public from python:latest (Docker Hub). Expect a large number of CVEs from the full Debian-based image and its bundled tooling.
./build-and-scan-cg.shBuilds demo-chainguard-python:cg from cgr.dev/chainguard/python:latest-dev with packages installed from the public PyPI index. The minimal Chainguard base dramatically reduces the CVE count compared to Step 1.
./build-and-scan-cg-libs.shBuilds demo-chainguard-python:cg-libs from cgr.dev/chainguard/python:latest-dev with packages pulled from the Chainguard pip registry. Packages are built, scanned, and signed by Chainguard before serving.
Before running this step, ensure you have:
- Run
chainctl auth configure-pip --pull-tokento generate credentials. - A
.netrcfile with valid Chainguard Library credentials (used bycg-libs.Dockerfile). - A
pip.conf.cgfile pointing tolibraries.cgr.dev.
| Dockerfile | Base image | pip source | Image tag |
|---|---|---|---|
Dockerfile |
python:latest |
pypi.org | demo-chainguard-python:public |
cg.Dockerfile |
cgr.dev/chainguard/python:latest-dev |
pypi.org | demo-chainguard-python:cg |
cg-libs.Dockerfile |
cgr.dev/chainguard/python:latest-dev |
libraries.cgr.dev |
demo-chainguard-python:cg-libs |