|
| 1 | +#!/bin/bash |
| 2 | +set -euxo pipefail |
| 3 | + |
| 4 | +# ============================================================ |
| 5 | +# Track Setup: Pre-warm the Go module + build cache for ex2 tsnet. |
| 6 | +# |
| 7 | +# Runs during hot-start pool prewarm, before invite association. |
| 8 | +# Runtime parameters (TS_AUTHKEY, INSTRUQT_USER_NAME, etc.) are |
| 9 | +# NOT available here, so this script is scoped to work that |
| 10 | +# needs only the network and disk. |
| 11 | +# |
| 12 | +# Challenge 1's setup-workshop runs the same warmup at the end |
| 13 | +# as a fallback for cold-start cases (empty pool). When this |
| 14 | +# script ran first, ex1's `go mod download` / `go build` are |
| 15 | +# no-ops because $GOCACHE / $GOMODCACHE are already populated. |
| 16 | +# ============================================================ |
| 17 | + |
| 18 | +# Wait for Instruqt host bootstrap before touching the system. |
| 19 | +until [ -f /opt/instruqt/bootstrap/host-bootstrap-completed ]; do |
| 20 | + sleep 1 |
| 21 | +done |
| 22 | + |
| 23 | +REPO_URL="https://github.com/temporal-community/workshop-tailscale-replay-2026.git" |
| 24 | +WORKSHOP_DIR="/root/workshop" |
| 25 | + |
| 26 | +# --- Install Go --- |
| 27 | +# tar -xzf overwrites in place, so ex1 setup re-extracting the |
| 28 | +# same archive into /usr/local is idempotent. |
| 29 | + |
| 30 | +GO_VERSION="1.26.2" |
| 31 | +curl -LsSf "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xzf - |
| 32 | +export PATH="/usr/local/go/bin:$PATH" |
| 33 | + |
| 34 | +# --- Sparse-clone the workshop repo with ex2 included --- |
| 35 | +# Same target directory as ex1 setup; ex1's `if [ ! -d ... ]` |
| 36 | +# guard skips re-cloning when this script already populated it. |
| 37 | +# Ex1 setup later resets the sparse-checkout to ex1-only at the |
| 38 | +# end of its run, so the attendee's Code Editor tree stays clean. |
| 39 | + |
| 40 | +if [ ! -d "$WORKSHOP_DIR" ]; then |
| 41 | + git clone --no-checkout "$REPO_URL" "$WORKSHOP_DIR" |
| 42 | + cd "$WORKSHOP_DIR" |
| 43 | + git sparse-checkout set --no-cone \ |
| 44 | + '/pyproject.toml' \ |
| 45 | + '/uv.lock' \ |
| 46 | + '/temporal.toml' \ |
| 47 | + '/exercises/02_explore_tailscale/**' |
| 48 | + git checkout |
| 49 | +fi |
| 50 | + |
| 51 | +# --- Warm Go module + build cache for ex2 tsnet --- |
| 52 | +# tsnet pulls in ~160 transitive Go modules. Compiling them cold |
| 53 | +# on n1-standard-2 takes 3-5 minutes. $GOCACHE / $GOMODCACHE |
| 54 | +# persist from this prewarm into the participant's challenge |
| 55 | +# session (same VM under hot start), so the attendee's first |
| 56 | +# `go run` in ex2 is instant. |
| 57 | + |
| 58 | +cd "$WORKSHOP_DIR/exercises/02_explore_tailscale/go-hello-tsnet/solution" |
| 59 | +go mod download |
| 60 | +go build -o /dev/null . |
| 61 | + |
| 62 | +echo "==> Track-level prewarm complete." |
0 commit comments