Lab 4 — Minimal ML inference image¶

Goal. Build a Docker image for a single-model inference service. Target image size under 500 MB. Push to a registry.

What you ship. Docker image on a public registry, runnable in one docker run command. README with image size and build time.

Setup¶

Install the dependencies (one-time).

In [ ]:
# !pip install (none — Docker is the focus)
In [ ]:
import subprocess, pathlib

What you build at the shell, structured as a walkthrough¶

In [ ]:
# Lab directory
LAB = pathlib.Path('mlops-lab04')
LAB.mkdir(exist_ok=True)
print('working in:', LAB.resolve())

Exercise 1 — Write a multi-stage Dockerfile¶

In [ ]:
# YOUR TURN
# Stage 1 (builder): install Python + dependencies into a virtualenv
# Stage 2 (runtime): COPY the virtualenv from builder, drop build tooling

Exercise 2 — Build, tag, and check size¶

In [ ]:
# !docker build -t yourname/ml-inference:0.1 .
# !docker images yourname/ml-inference:0.1
# Target: under 500 MB.

Exercise 3 — Push to a public registry¶

In [ ]:
# !docker login
# !docker push yourname/ml-inference:0.1

Done?¶

Submit per the cohort schedule. Peer review pairing announced the following Monday.