#!/usr/bin/env bash # run-dev.sh — build and run Slides locally, with no setup at all. # # scripts/run-dev.sh # http://localhost:8091 # SLIDES_DEV_PORT=9000 scripts/run-dev.sh # # It runs with -env development, which is the ONLY way that env can be # selected (cmd/slides/main.go's chooseEnv refuses to honour it from # $SLIDES_ENV, so a deployment's env-var block can never reach this # mode). In development, and nowhere else, four settings default: # # * the instance key becomes a fixed, public string; # * mail is written to this terminal instead of being sent, so the # magic link is the line marked "magic links will be logged"; # * the allowlist admits every address; # * the object store is a directory beside the scratch database. # # Sign in by entering any address at http://localhost:8091/signin, then # copying the /auth/verify?token=... link out of the log below into the # browser. # # The database is a scratch file under $TMPDIR, thrown away with it: # nothing this script runs should ever be pointed at data that matters. set -euo pipefail cd "$(dirname "$0")/.." port="${SLIDES_DEV_PORT:-8091}" tmp="${TMPDIR:-/tmp}" state="${tmp%/}/slides-dev" mkdir -p "$state" # CGO_ENABLED=0 here as everywhere: the stack is cgo-free by design, and # a local build that quietly used cgo would not be the binary CI checks. CGO_ENABLED=0 go build -o "$state/slides" ./cmd/slides echo "slides: http://localhost:$port (database: $state/slides.db)" echo "slides: sign in at http://localhost:$port/signin — the magic link is logged below" # -addr is what main.go derives the origin from when $SLIDES_ORIGIN is # unset, and it has to be the host a browser will actually send back as # its own Origin header — hence localhost, not a bare :port. exec "$state/slides" \ -env development \ -addr "localhost:$port" \ -db "$state/slides.db"