#!/usr/bin/env bash
# Real demos for P108 "Golang REST API with Gin: Full Tutorial for Beginners". Runs on the Mac's Docker Desktop.
# One stock Ubuntu 24.04 container stands in for Ana's laptop (lab/Dockerfile, Go from the official image); Gin is
# fetched on camera with go get. Two real bash windows in a pty (demo_driver.py): Ana's terminal, and a second one
# running the API with go run, whose log is shown as its own window. Ana's files (what she types in her editor) are
# copied into the project off camera from lab/steps/s1..s10 and shown with cat. The API's port is published on the
# Mac's 127.0.0.1:18080 only, so a real Chromium can load one page of it (shots/).
set -euo pipefail
cd "$(dirname "$0")"
P=ce-p108
cleanup() { docker rm -f $P-laptop >/dev/null 2>&1 || true; }
cleanup
[ -n "${KEEP:-}" ] || trap cleanup EXIT
docker build -q -t $P-laptop lab >/dev/null
docker run -d --name $P-laptop --hostname laptop -p 127.0.0.1:18080:8080 $P-laptop >/dev/null
sleep 1
PYTHONPATH=../.. python3 - "$P" < demo_driver.py
