From 7bd4d811cda57c31695a770187c89137750148b3 Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Thu, 18 Dec 2025 19:34:05 +0100 Subject: [PATCH] feat: Add script and configuration for remote Drizzle Studio access via SSH tunnel. --- .env.example | 3 +++ package.json | 3 ++- scripts/remote-studio.sh | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 scripts/remote-studio.sh diff --git a/.env.example b/.env.example index 5eff022..87e4520 100644 --- a/.env.example +++ b/.env.example @@ -7,3 +7,6 @@ DISCORD_BOT_TOKEN=your-discord-bot-token DISCORD_CLIENT_ID=your-discord-client-id DISCORD_GUILD_ID=your-discord-guild-id DATABASE_URL=postgres://kyoko:kyoko@db:5432/kyoko + +VPS_USER=your-vps-user +VPS_HOST=your-vps-ip diff --git a/package.json b/package.json index d3f7fb6..f03638c 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "db:push": "docker compose run --rm app drizzle-kit push", "db:push:local": "drizzle-kit push", "dev": "bun --watch src/index.ts", - "db:studio": "drizzle-kit studio --host 0.0.0.0" + "db:studio": "drizzle-kit studio --host 0.0.0.0", + "studio:remote": "bash scripts/remote-studio.sh" }, "dependencies": { "@napi-rs/canvas": "^0.1.84", diff --git a/scripts/remote-studio.sh b/scripts/remote-studio.sh new file mode 100755 index 0000000..2484260 --- /dev/null +++ b/scripts/remote-studio.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Load environment variables +if [ -f .env ]; then + # export $(grep -v '^#' .env | xargs) # Use a safer way if possible, but for simple .env this often works. + # Better way to source .env without exporting everything to shell if we just want to use them in script: + set -a + source .env + set +a +fi + +if [ -z "$VPS_HOST" ] || [ -z "$VPS_USER" ]; then + echo "Error: VPS_HOST and VPS_USER must be set in .env" + echo "Please add them to your .env file:" + echo "VPS_USER=your-username" + echo "VPS_HOST=your-ip-address" + exit 1 +fi + +echo "🔮 Establishing secure tunnel to Drizzle Studio..." +echo "📚 Studio will be accessible at: https://local.drizzle.studio" +echo "Press Ctrl+C to stop the connection." + +# -N means "Do not execute a remote command". -L is for local port forwarding. +ssh -N -L 4983:127.0.0.1:4983 $VPS_USER@$VPS_HOST