#!/usr/bin/env bash
# Real demos for P159 "Golang Interfaces and Mocks in 5 Minutes". Made on the Mac (Docker Desktop).
# Tom runs a roadside egg stand with a card reader, in Go, ~/eggs. One container from a stock Ubuntu 24.04 image
# (lab/Dockerfile) with Go copied in from the official golang image, plus cardsvc, a small stand-in for the payment
# company's card service on 127.0.0.1:9000, started and stopped off camera. Each version of the Go files Tom types
# waits in lab/steps/<name>/ and is copied in off camera; one real interactive bash in a pty (demo_driver.py) and
# every line of output is real.
set -euo pipefail
cd "$(dirname "$0")"
cleanup() { docker rm -f ce-p159-laptop >/dev/null 2>&1 || true; }
cleanup
[ -n "${KEEP:-}" ] || trap cleanup EXIT
docker build -q -t ce-p159 lab >/dev/null
docker run -d --name ce-p159-laptop --hostname laptop ce-p159 >/dev/null
python3 demo_driver.py
