Sidecar architecture: edge functions (auth + DB) → youtube-worker container (youtubei.js for playlist metadata, yt-dlp for audio downloads). - Edge functions: youtube-playlist, youtube-process, youtube-status (CRUD) - youtube-worker sidecar: Node.js + yt-dlp, downloads M4A to Supabase Storage - Admin music page: import playlists, process queue, inline genre editing - 12 music genres with per-track assignment and import-time defaults - DB migrations: download_jobs, download_items tables with genre column - Deploy script and CI workflow for edge functions + sidecar
56 lines
2.3 KiB
Bash
Executable File
56 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# ── Configuration ──────────────────────────────────────────────
|
|
DEPLOY_HOST="${DEPLOY_HOST:-1000co.fr}"
|
|
DEPLOY_USER="${DEPLOY_USER:-millian}"
|
|
DEPLOY_PATH="${DEPLOY_PATH:-/opt/supabase/volumes/functions}"
|
|
WORKER_PATH="${WORKER_PATH:-/opt/supabase/youtube-worker}"
|
|
# ───────────────────────────────────────────────────────────────
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
FUNCTIONS_DIR="$SCRIPT_DIR/../supabase/functions"
|
|
WORKER_DIR="$SCRIPT_DIR/../youtube-worker"
|
|
|
|
# ── Deploy edge functions ──────────────────────────────────────
|
|
echo "==> Deploying edge functions"
|
|
rsync -avz --delete \
|
|
--exclude='node_modules' \
|
|
--exclude='.DS_Store' \
|
|
"$FUNCTIONS_DIR/" \
|
|
"$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/"
|
|
|
|
echo "Restarting supabase-edge-functions..."
|
|
ssh "$DEPLOY_USER@$DEPLOY_HOST" "docker restart supabase-edge-functions"
|
|
|
|
# ── Deploy youtube-worker sidecar ──────────────────────────────
|
|
echo ""
|
|
echo "==> Deploying youtube-worker sidecar"
|
|
rsync -avz --delete \
|
|
--exclude='node_modules' \
|
|
--exclude='.DS_Store' \
|
|
"$WORKER_DIR/" \
|
|
"$DEPLOY_USER@$DEPLOY_HOST:$WORKER_PATH/"
|
|
|
|
echo "Building and restarting youtube-worker..."
|
|
ssh "$DEPLOY_USER@$DEPLOY_HOST" "\
|
|
cd $WORKER_PATH && \
|
|
docker build -t youtube-worker:latest . && \
|
|
docker stop youtube-worker 2>/dev/null || true && \
|
|
docker rm youtube-worker 2>/dev/null || true && \
|
|
docker run -d \
|
|
--name youtube-worker \
|
|
--restart unless-stopped \
|
|
--network supabase_supabase-network \
|
|
-e SUPABASE_URL=\$(docker exec supabase-edge-functions printenv SUPABASE_URL) \
|
|
-e SUPABASE_SERVICE_ROLE_KEY=\$(docker exec supabase-edge-functions printenv SUPABASE_SERVICE_ROLE_KEY) \
|
|
-e SUPABASE_PUBLIC_URL=https://supabase.1000co.fr \
|
|
-e STORAGE_BUCKET=workout-audio \
|
|
-e PORT=3001 \
|
|
youtube-worker:latest"
|
|
|
|
echo ""
|
|
echo "Done. Verifying youtube-worker health..."
|
|
sleep 3
|
|
ssh "$DEPLOY_USER@$DEPLOY_HOST" "docker logs youtube-worker --tail 5"
|