Goal: Containerize a small scikit-learn inference app in a single-stage Dockerfile, measure its size, refactor it into a multi-stage build, then tag it with semantic versions, push it to Docker Hub, and scan it with Trivy. Steps:
docker --version.week03-lab) with train_and_serve.py (< 30 lines) that trains a classifier on sklearn.datasets.load_iris(), saves it with joblib, reloads it, and prints a sample prediction. Add a requirements.txt (e.g. scikit-learn, joblib).FROM python:3.11, COPY requirements.txt and pip install -r requirements.txt, then COPY your script and set it as CMD. Build and tag: docker build -t iris-classifier:single-stage .. Check size with docker image ls and record it. Run with docker run --rm iris-classifier:single-stage to confirm the prediction prints.builder stage FROM python:3.11 installs dependencies; a final stage FROM python:3.11-slim uses COPY --from=builder to bring across only installed packages and your script. Add a non-root user (RUN useradd -m appuser, USER appuser, COPY --chown=appuser:appuser).docker build -t iris-classifier:multi-stage .. Check size again, calculate the percentage reduction versus single-stage, and run it to confirm the prediction is still correct.docker login.docker tag iris-classifier:multi-stage <username>/iris-classifier:v1.0.0 and <username>/iris-classifier:latest. Push both: docker push <username>/iris-classifier:v1.0.0 then ...:latest. Confirm both tags appear on your Docker Hub repo page.pip install trivy or the single-binary release for your OS); verify with trivy --version. Scan your pushed image: trivy image <username>/iris-classifier:v1.0.0.Deliverables: Both Dockerfiles, train_and_serve.py, requirements.txt, a screenshot or text export of your Docker Hub tags page, your Trivy findings table, and your written report (file upload or pasted text).