From ee231d2ee5c131b8c14b0ffc2d961f5db159f929 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 10 May 2026 14:55:53 +0100 Subject: [PATCH] Make vide work with prod --- video/auth.prod.json | 22 +++++++ video/render.sh | 132 ++++++++++++++++++++++++++++++--------- video/src/auth.ts | 65 +++++++++---------- video/src/config.ts | 4 +- video/src/pb-admin.ts | 4 +- video/tts/pyproject.toml | 12 ++++ video/tts/uv.lock | 25 ++++++++ 7 files changed, 197 insertions(+), 67 deletions(-) create mode 100644 video/auth.prod.json diff --git a/video/auth.prod.json b/video/auth.prod.json new file mode 100644 index 0000000..7790d13 --- /dev/null +++ b/video/auth.prod.json @@ -0,0 +1,22 @@ +{ + "cookies": [], + "origins": [ + { + "origin": "https://perfect-postcode.co.uk", + "localStorage": [ + { + "name": "theme", + "value": "light" + }, + { + "name": "pocketbase_auth", + "value": "{\"token\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2xsZWN0aW9uSWQiOiJfcGJfdXNlcnNfYXV0aF8iLCJleHAiOjE3Nzg5NDgxMzIsImlkIjoiZDZ5aG9odWh3MHh5dHhwIiwicmVmcmVzaGFibGUiOnRydWUsInR5cGUiOiJhdXRoIn0.bOR_vxK2MvqeKc_C9ao13416n_F-Ipmbn53NJy6L_JU\",\"record\":{\"ai_tokens_used\":0,\"ai_tokens_week\":0,\"avatar\":\"\",\"collectionId\":\"_pb_users_auth_\",\"collectionName\":\"users\",\"created\":\"2026-03-14 21:50:46.000Z\",\"email\":\"schmelczerandras+10@gmail.com\",\"emailVisibility\":false,\"id\":\"d6yhohuhw0xytxp\",\"is_admin\":false,\"name\":\"\",\"newsletter\":false,\"subscription\":\"licensed\",\"updated\":\"2026-03-14 21:50:48.430Z\",\"verified\":false}}" + }, + { + "name": "tutorial_completed", + "value": "1" + } + ] + } + ] +} \ No newline at end of file diff --git a/video/render.sh b/video/render.sh index dc800a3..6967aa3 100755 --- a/video/render.sh +++ b/video/render.sh @@ -2,30 +2,81 @@ # # End-to-end re-render of the dashboard demo video. # -# Defaults assume you run from inside this repo's vscode-server container -# (where host.docker.internal reaches the docker-compose stack). Override -# any URL/credential via env vars at the top. +# Two targets: +# local (default) — assumes the docker-compose stack on host.docker.internal, +# bootstraps a recorder admin user automatically. +# prod — points at https://perfect-postcode.co.uk and skips the +# bootstrap step; you supply real account credentials. # # Usage: -# ./render.sh # full pipeline (uses cached auth.json if fresh) -# ./render.sh --fresh-auth # force re-auth even if auth.json exists -# ./render.sh --no-encode # stop at WebM, skip MP4 encode -# ./render.sh --no-audio # skip Qwen3-TTS narration; publish silent MP4 -# FORCE_AUTH=1 ./render.sh # same as --fresh-auth +# ./render.sh # local stack +# ./render.sh --prod # prod (requires LOGIN_EMAIL/LOGIN_PASSWORD) +# ./render.sh --target prod # same as --prod +# ./render.sh --fresh-auth # force re-auth even if cache is fresh +# ./render.sh --no-encode # stop at WebM, skip MP4 encode +# ./render.sh --no-audio # skip Qwen3-TTS narration; silent MP4 +# FORCE_AUTH=1 ./render.sh # same as --fresh-auth # APP_URL=http://localhost:3001 ./render.sh # override frontend URL # TTS_SPEAKER=aiden ./render.sh # override CustomVoice speaker +# +# Cred env vars (read for both targets, but prod has no fallback defaults): +# LOGIN_EMAIL, LOGIN_PASSWORD — the dashboard account to record as +# (same email/password you'd type into +# the login modal) +# PB_ADMIN_EMAIL, PB_ADMIN_PASSWORD — PocketBase superuser, only used by +# --target local to bootstrap the +# recorder user; ignored on --prod set -euo pipefail +# -- target ------------------------------------------------------------------- +TARGET="${TARGET:-local}" +parsed_args=() +while [ $# -gt 0 ]; do + case "$1" in + --prod) TARGET=prod; shift ;; + --local) TARGET=local; shift ;; + --target) TARGET="$2"; shift 2 ;; + --target=*) TARGET="${1#--target=}"; shift ;; + *) parsed_args+=("$1"); shift ;; + esac +done +set -- "${parsed_args[@]+"${parsed_args[@]}"}" + +case "$TARGET" in + local|prod) ;; + *) echo "Unknown --target: $TARGET (expected: local, prod)" >&2; exit 2 ;; +esac + # -- config (override via env) ------------------------------------------------- -export APP_URL="${APP_URL:-http://host.docker.internal:3001}" -export PB_URL="${PB_URL:-http://host.docker.internal:8090}" -export API_URL="${API_URL:-http://host.docker.internal:8001}" -PB_ADMIN_EMAIL="${PB_ADMIN_EMAIL:-admin@propertymap.local}" -PB_ADMIN_PASSWORD="${PB_ADMIN_PASSWORD:-propertymap-dev-2024}" -PB_EMAIL="${PB_EMAIL:-demo-video@local.test}" -PB_PASSWORD="${PB_PASSWORD:-DemoVideoPass123!}" -AUTH_TTL_HOURS="${AUTH_TTL_HOURS:-24}" # re-auth if auth.json older than this +if [ "$TARGET" = "prod" ]; then + # Prod serves frontend, /api/*, and /pb/* off the same domain. + export APP_URL="${APP_URL:-https://perfect-postcode.co.uk}" + export PB_URL="${PB_URL:-https://perfect-postcode.co.uk/pb}" + export API_URL="${API_URL:-https://perfect-postcode.co.uk}" + # Prod has no recorder-bootstrap path: the user supplies a real account. + PB_BOOTSTRAP_ADMIN="${PB_BOOTSTRAP_ADMIN:-0}" + if [ -z "${LOGIN_EMAIL:-}" ] || [ -z "${LOGIN_PASSWORD:-}" ]; then + echo "FAIL: --prod requires LOGIN_EMAIL and LOGIN_PASSWORD (your dashboard login)." >&2 + echo " Example: LOGIN_EMAIL=you@example.com LOGIN_PASSWORD='...' $0 --prod" >&2 + exit 2 + fi +else + export APP_URL="${APP_URL:-http://host.docker.internal:3001}" + export PB_URL="${PB_URL:-http://host.docker.internal:8090}" + export API_URL="${API_URL:-http://host.docker.internal:8001}" + PB_ADMIN_EMAIL="${PB_ADMIN_EMAIL:-admin@propertymap.local}" + PB_ADMIN_PASSWORD="${PB_ADMIN_PASSWORD:-propertymap-dev-2024}" + LOGIN_EMAIL="${LOGIN_EMAIL:-demo-video@local.test}" + LOGIN_PASSWORD="${LOGIN_PASSWORD:-DemoVideoPass123!}" + PB_BOOTSTRAP_ADMIN="${PB_BOOTSTRAP_ADMIN:-1}" +fi +export PB_BOOTSTRAP_ADMIN +export LOGIN_EMAIL LOGIN_PASSWORD +# Per-target storage state — switching targets must not reuse a stale token. +# config.ts reads AUTH_STATE_FILE for AUTH_STATE_PATH. +export AUTH_STATE_FILE="${AUTH_STATE_FILE:-auth.${TARGET}.json}" +AUTH_TTL_HOURS="${AUTH_TTL_HOURS:-24}" # re-auth if cache older than this # Where the homepage