#!/usr/bin/env bash
# Real demos for P154 "Golang context.Context in 5 Minutes". Made on the Mac (Docker Desktop).
# John keeps the garden center's stock-check server in Go, ~/garden. One container from a stock Ubuntu 24.04 image
# (lab/Dockerfile) with Go copied in from the official golang image and a slow stand-in supplier (8 s per answer).
# Each version of main.go John types waits in lab/steps/<name>/main.go and is copied in off camera; two real interactive bash windows in ptys
# (the server and a customer's curl, demo_driver.py) and every line of output is real.
set -euo pipefail
cd "$(dirname "$0")"
cleanup() { docker rm -f ce-p154-laptop >/dev/null 2>&1 || true; }
cleanup
[ -n "${KEEP:-}" ] || trap cleanup EXIT
docker build -q -t ce-p154 lab >/dev/null
docker run -d --name ce-p154-laptop --hostname laptop ce-p154 >/dev/null
python3 demo_driver.py
