feat: Add script and configuration for remote Drizzle Studio access via SSH tunnel.

This commit is contained in:
syntaxbullet
2025-12-18 19:34:05 +01:00
parent 2ce768013d
commit 7bd4d811cd
3 changed files with 30 additions and 1 deletions

View File

@@ -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

View File

@@ -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",

25
scripts/remote-studio.sh Executable file
View File

@@ -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