fix: Applied fix for name, the oracle team sharing, sentinel client list visibility
This commit is contained in:
122
scripts/export_velocity_local_bundle.sh
Normal file
122
scripts/export_velocity_local_bundle.sh
Normal file
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Run this on the Linux origin host that currently serves velocity.desineuron.in.
|
||||
# It exports a local-development bundle containing:
|
||||
# - backend env snapshot (non-shell format)
|
||||
# - PostgreSQL custom-format dump
|
||||
# - app build metadata
|
||||
# - optional asset snapshot manifest
|
||||
#
|
||||
# Output:
|
||||
# /tmp/velocity-local-bundle-YYYYmmdd-HHMMSS.tar.gz
|
||||
|
||||
REPO_ROOT="${REPO_ROOT:-/opt/desineuron-velocity-site/repo}"
|
||||
BACKEND_ENV_PATH="${BACKEND_ENV_PATH:-$REPO_ROOT/backend/.env}"
|
||||
OUTPUT_ROOT="${OUTPUT_ROOT:-/tmp}"
|
||||
DB_CONTAINER_NAME="${DB_CONTAINER_NAME:-desineuron-ops-db}"
|
||||
STAMP="$(date +%Y%m%d-%H%M%S)"
|
||||
WORKDIR="$OUTPUT_ROOT/velocity-local-bundle-$STAMP"
|
||||
ARCHIVE="$OUTPUT_ROOT/velocity-local-bundle-$STAMP.tar.gz"
|
||||
|
||||
if [[ ! -f "$BACKEND_ENV_PATH" ]]; then
|
||||
echo "Missing backend env file: $BACKEND_ENV_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$WORKDIR"
|
||||
|
||||
cp "$BACKEND_ENV_PATH" "$WORKDIR/backend.env.raw"
|
||||
|
||||
python3 - "$WORKDIR/backend.env.raw" "$WORKDIR/backend.env.export" <<'PY'
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
src = pathlib.Path(sys.argv[1])
|
||||
dst = pathlib.Path(sys.argv[2])
|
||||
|
||||
allowed = {
|
||||
"VELOCITY_DB_HOST",
|
||||
"VELOCITY_DB_PORT",
|
||||
"VELOCITY_DB_NAME",
|
||||
"VELOCITY_DB_USER",
|
||||
"VELOCITY_DB_PASSWORD",
|
||||
"DATABASE_URL",
|
||||
"CORS_ORIGINS",
|
||||
"VELOCITY_ASSET_DIR",
|
||||
"JWT_SECRET_KEY",
|
||||
"JWT_ALGORITHM",
|
||||
"JWT_EXP_MINUTES",
|
||||
}
|
||||
|
||||
lines = []
|
||||
for raw_line in src.read_text(encoding="utf-8").splitlines():
|
||||
line = raw_line.strip()
|
||||
if not line or line.startswith("#") or "=" not in line:
|
||||
continue
|
||||
key, value = line.split("=", 1)
|
||||
key = key.strip()
|
||||
if key in allowed:
|
||||
lines.append(f"{key}={value.strip()}")
|
||||
|
||||
dst.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||
PY
|
||||
|
||||
set -a
|
||||
source "$BACKEND_ENV_PATH"
|
||||
set +a
|
||||
|
||||
dump_with_local_pg_dump() {
|
||||
PGPASSWORD="${VELOCITY_DB_PASSWORD}" pg_dump \
|
||||
-h "${VELOCITY_DB_HOST}" \
|
||||
-p "${VELOCITY_DB_PORT}" \
|
||||
-U "${VELOCITY_DB_USER}" \
|
||||
-d "${VELOCITY_DB_NAME}" \
|
||||
-Fc \
|
||||
-f "$WORKDIR/velocity.dump"
|
||||
}
|
||||
|
||||
dump_with_docker_exec() {
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
sudo -n docker exec \
|
||||
-e PGPASSWORD="${VELOCITY_DB_PASSWORD}" \
|
||||
"$DB_CONTAINER_NAME" \
|
||||
pg_dump \
|
||||
-U "${VELOCITY_DB_USER}" \
|
||||
-d "${VELOCITY_DB_NAME}" \
|
||||
-Fc \
|
||||
> "$WORKDIR/velocity.dump"
|
||||
}
|
||||
|
||||
if command -v pg_dump >/dev/null 2>&1; then
|
||||
dump_with_local_pg_dump
|
||||
elif dump_with_docker_exec; then
|
||||
:
|
||||
else
|
||||
echo "Neither host pg_dump nor docker-exec pg_dump is available." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat > "$WORKDIR/README.txt" <<EOF
|
||||
Velocity local bundle
|
||||
Created: $(date --iso-8601=seconds)
|
||||
Repo root: $REPO_ROOT
|
||||
Bundle contents:
|
||||
- backend.env.export
|
||||
- velocity.dump
|
||||
- restore.instructions.txt
|
||||
EOF
|
||||
|
||||
cat > "$WORKDIR/restore.instructions.txt" <<EOF
|
||||
1. Copy this archive to the Windows development machine.
|
||||
2. Extract it under Project_Velocity/.local-dev/source-bundles/<bundle-name>.
|
||||
3. Run scripts/import_velocity_local_bundle.ps1 from the repo root.
|
||||
EOF
|
||||
|
||||
tar -C "$OUTPUT_ROOT" -czf "$ARCHIVE" "$(basename "$WORKDIR")"
|
||||
rm -rf "$WORKDIR"
|
||||
|
||||
echo "Created bundle: $ARCHIVE"
|
||||
140
scripts/import_velocity_local_bundle.ps1
Normal file
140
scripts/import_velocity_local_bundle.ps1
Normal file
@@ -0,0 +1,140 @@
|
||||
param(
|
||||
[string]$BundleRoot = "",
|
||||
[string]$RepoRoot = "F:\Workin In Progress\DESINEURON\GITLAB\Project_Velocity"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
if (-not $BundleRoot) {
|
||||
$candidate = Join-Path $RepoRoot ".local-dev\source-bundles"
|
||||
if (-not (Test-Path $candidate)) {
|
||||
throw "Bundle root not provided and no source bundles found at $candidate"
|
||||
}
|
||||
|
||||
$latest = Get-ChildItem -Path $candidate -Directory | Sort-Object LastWriteTime -Descending | Select-Object -First 1
|
||||
if (-not $latest) {
|
||||
throw "No extracted bundle directories found under $candidate"
|
||||
}
|
||||
$BundleRoot = $latest.FullName
|
||||
}
|
||||
|
||||
$envExport = Join-Path $BundleRoot "backend.env.export"
|
||||
$dumpFile = Join-Path $BundleRoot "velocity.dump"
|
||||
|
||||
if (-not (Test-Path $envExport)) {
|
||||
throw "Missing backend.env.export in $BundleRoot"
|
||||
}
|
||||
|
||||
if (-not (Test-Path $dumpFile)) {
|
||||
throw "Missing velocity.dump in $BundleRoot"
|
||||
}
|
||||
|
||||
$localRoot = Join-Path $RepoRoot ".local-dev"
|
||||
$backendRoot = Join-Path $localRoot "backend"
|
||||
$dbRoot = Join-Path $localRoot "db"
|
||||
$assetsRoot = Join-Path $localRoot "assets"
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $localRoot, $backendRoot, $dbRoot, $assetsRoot | Out-Null
|
||||
|
||||
$targetEnv = Join-Path $backendRoot ".env.local"
|
||||
$restoreScript = Join-Path $dbRoot "restore_local_snapshot.ps1"
|
||||
$composeFile = Join-Path $dbRoot "docker-compose.local-db.yml"
|
||||
$copiedDump = Join-Path $dbRoot "velocity.dump"
|
||||
|
||||
Copy-Item $dumpFile $copiedDump -Force
|
||||
|
||||
$rawEnv = @{}
|
||||
Get-Content $envExport | ForEach-Object {
|
||||
if ($_ -match '^\s*#' -or $_ -notmatch '=') {
|
||||
return
|
||||
}
|
||||
$key, $value = $_ -split '=', 2
|
||||
$rawEnv[$key.Trim()] = $value.Trim()
|
||||
}
|
||||
|
||||
$localEnvLines = [System.Collections.Generic.List[string]]::new()
|
||||
$localEnvLines.Add("VELOCITY_DB_HOST=127.0.0.1")
|
||||
$localEnvLines.Add("VELOCITY_DB_PORT=54329")
|
||||
$localEnvLines.Add("VELOCITY_DB_NAME=velocity_local")
|
||||
$localEnvLines.Add("VELOCITY_DB_USER=velocity_local")
|
||||
$localEnvLines.Add("VELOCITY_DB_PASSWORD=velocity_local")
|
||||
$localEnvLines.Add("DATABASE_URL=postgresql://velocity_local:velocity_local@127.0.0.1:54329/velocity_local")
|
||||
$localEnvLines.Add("CORS_ORIGINS=http://127.0.0.1:5173,http://localhost:5173,http://127.0.0.1:3000,http://localhost:3000")
|
||||
|
||||
if ($rawEnv.ContainsKey("VELOCITY_JWT_SECRET")) {
|
||||
$localEnvLines.Add("VELOCITY_JWT_SECRET=$($rawEnv['VELOCITY_JWT_SECRET'])")
|
||||
}
|
||||
|
||||
if ($rawEnv.ContainsKey("JWT_SECRET_KEY")) {
|
||||
$localEnvLines.Add("JWT_SECRET_KEY=$($rawEnv['JWT_SECRET_KEY'])")
|
||||
}
|
||||
|
||||
if ($rawEnv.ContainsKey("JWT_ALGORITHM")) {
|
||||
$localEnvLines.Add("JWT_ALGORITHM=$($rawEnv['JWT_ALGORITHM'])")
|
||||
}
|
||||
|
||||
if ($rawEnv.ContainsKey("JWT_EXP_MINUTES")) {
|
||||
$localEnvLines.Add("JWT_EXP_MINUTES=$($rawEnv['JWT_EXP_MINUTES'])")
|
||||
}
|
||||
|
||||
$localAssetsRoot = Join-Path $localRoot "assets"
|
||||
$localEnvLines.Add("VELOCITY_ASSET_DIR=$localAssetsRoot")
|
||||
|
||||
Set-Content -Path $targetEnv -Value ($localEnvLines -join "`r`n") -Encoding UTF8
|
||||
|
||||
$compose = @"
|
||||
services:
|
||||
velocity-postgres-local:
|
||||
image: postgres:16
|
||||
container_name: velocity-postgres-local
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: velocity_local
|
||||
POSTGRES_USER: velocity_local
|
||||
POSTGRES_PASSWORD: velocity_local
|
||||
ports:
|
||||
- "54329:5432"
|
||||
volumes:
|
||||
- velocity_postgres_local_data:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
velocity_postgres_local_data:
|
||||
"@
|
||||
|
||||
Set-Content -Path $composeFile -Value $compose -Encoding UTF8
|
||||
|
||||
$restoreTemplate = @'
|
||||
param(
|
||||
[string]$RepoRoot = "__REPO_ROOT__"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$DbRoot = Join-Path $RepoRoot ".local-dev\db"
|
||||
$Compose = Join-Path $DbRoot "docker-compose.local-db.yml"
|
||||
$Dump = Join-Path $DbRoot "velocity.dump"
|
||||
|
||||
docker compose -f $Compose up -d
|
||||
Start-Sleep -Seconds 4
|
||||
docker exec -i velocity-postgres-local dropdb --if-exists -U velocity_local velocity_local
|
||||
docker exec -i velocity-postgres-local createdb -U velocity_local velocity_local
|
||||
docker cp $Dump velocity-postgres-local:/tmp/velocity.dump
|
||||
docker exec -i velocity-postgres-local pg_restore -U velocity_local -d velocity_local --clean --if-exists --no-owner --no-privileges /tmp/velocity.dump
|
||||
|
||||
Write-Host "Local PostgreSQL restore complete."
|
||||
Write-Host "Use these local DB env values:"
|
||||
Write-Host "VELOCITY_DB_HOST=127.0.0.1"
|
||||
Write-Host "VELOCITY_DB_PORT=54329"
|
||||
Write-Host "VELOCITY_DB_NAME=velocity_local"
|
||||
Write-Host "VELOCITY_DB_USER=velocity_local"
|
||||
Write-Host "VELOCITY_DB_PASSWORD=velocity_local"
|
||||
'@
|
||||
|
||||
$restore = $restoreTemplate.Replace("__REPO_ROOT__", $RepoRoot)
|
||||
|
||||
Set-Content -Path $restoreScript -Value $restore -Encoding UTF8
|
||||
|
||||
Write-Host "Imported local bundle from $BundleRoot"
|
||||
Write-Host "Backend env snapshot: $targetEnv"
|
||||
Write-Host "DB dump copied to: $copiedDump"
|
||||
Write-Host "Run this next:"
|
||||
Write-Host "powershell -ExecutionPolicy Bypass -File `"$restoreScript`""
|
||||
25
scripts/package_velocity_local_bundle.ps1
Normal file
25
scripts/package_velocity_local_bundle.ps1
Normal file
@@ -0,0 +1,25 @@
|
||||
param(
|
||||
[string]$RepoRoot = "F:\Workin In Progress\DESINEURON\GITLAB\Project_Velocity",
|
||||
[string]$OutputDir = "F:\Workin In Progress\DESINEURON\GITLAB\Project_Velocity\local-dev-bundles"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$localRoot = Join-Path $RepoRoot ".local-dev"
|
||||
if (-not (Test-Path $localRoot)) {
|
||||
throw "Missing .local-dev folder. Import a local bundle first."
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null
|
||||
|
||||
$stamp = Get-Date -Format "yyyyMMdd-HHmmss"
|
||||
$zipPath = Join-Path $OutputDir "project-velocity-local-dev-$stamp.zip"
|
||||
|
||||
if (Test-Path $zipPath) {
|
||||
Remove-Item $zipPath -Force
|
||||
}
|
||||
|
||||
Compress-Archive -Path (Join-Path $localRoot "*") -DestinationPath $zipPath -Force
|
||||
|
||||
Write-Host "Created local dev zip: $zipPath"
|
||||
Write-Host "This zip is gitignored and can be handed to Sayan and Sourik for local verification."
|
||||
28
scripts/start_velocity_backend_local.ps1
Normal file
28
scripts/start_velocity_backend_local.ps1
Normal file
@@ -0,0 +1,28 @@
|
||||
param(
|
||||
[string]$RepoRoot = "F:\Workin In Progress\DESINEURON\GITLAB\Project_Velocity",
|
||||
[int]$Port = 8001
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$env:VELOCITY_ENV_FILE = Join-Path $RepoRoot ".local-dev\backend\.env.local"
|
||||
if (-not (Test-Path $env:VELOCITY_ENV_FILE)) {
|
||||
throw "Missing local backend env file at $($env:VELOCITY_ENV_FILE). Import a local bundle first."
|
||||
}
|
||||
|
||||
$pythonExe = Join-Path $RepoRoot ".venv\Scripts\python.exe"
|
||||
if (-not (Test-Path $pythonExe)) {
|
||||
$pythonExe = Join-Path $RepoRoot "venv\Scripts\python.exe"
|
||||
}
|
||||
|
||||
if (-not (Test-Path $pythonExe)) {
|
||||
$pythonExe = "python"
|
||||
}
|
||||
|
||||
Push-Location $RepoRoot
|
||||
try {
|
||||
& $pythonExe -m uvicorn backend.main:app --reload --host 127.0.0.1 --port $Port
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
15
scripts/start_velocity_frontend_local.ps1
Normal file
15
scripts/start_velocity_frontend_local.ps1
Normal file
@@ -0,0 +1,15 @@
|
||||
param(
|
||||
[string]$RepoRoot = "F:\Workin In Progress\DESINEURON\GITLAB\Project_Velocity"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$env:VITE_BACKEND_PROXY_TARGET = "http://127.0.0.1:8001"
|
||||
|
||||
Push-Location (Join-Path $RepoRoot "app")
|
||||
try {
|
||||
npm run dev -- --host 127.0.0.1 --port 5173
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
Reference in New Issue
Block a user