scripts: improve demo reset and production prep

This commit is contained in:
Marco Allegretti 2026-01-29 00:44:25 +01:00
parent 180fe5f05d
commit f3a5edd91d
5 changed files with 38 additions and 31 deletions

View file

@ -19,16 +19,22 @@ if (-not $Force) {
Set-Location "$PSScriptRoot\.." Set-Location "$PSScriptRoot\.."
Write-Host "`n[1/4] Stopping demo containers..." -ForegroundColor Yellow $envFile = "compose/.env.demo"
podman-compose -f compose/demo.yml down if (-not (Test-Path $envFile) -and (Test-Path "compose/.env.demo.example")) {
$envFile = "compose/.env.demo.example"
}
$composeArgs = @("-f", "compose/demo.yml")
if (Test-Path $envFile) {
$composeArgs = @("--env-file", $envFile) + $composeArgs
}
Write-Host "`n[2/4] Removing demo database volume..." -ForegroundColor Yellow Write-Host "`n[1/3] Stopping demo containers and removing volumes..." -ForegroundColor Yellow
podman volume rm likwid_demo_data -f 2>$null podman-compose @composeArgs down --remove-orphans -v
Write-Host "`n[3/4] Starting fresh demo instance..." -ForegroundColor Yellow Write-Host "`n[2/3] Starting fresh demo instance..." -ForegroundColor Yellow
podman-compose -f compose/demo.yml up -d podman-compose @composeArgs up -d
Write-Host "`n[4/4] Waiting for services to be ready..." -ForegroundColor Yellow Write-Host "`n[3/3] Waiting for services to be ready..." -ForegroundColor Yellow
Start-Sleep -Seconds 10 Start-Sleep -Seconds 10
# Check if backend is responding # Check if backend is responding
@ -56,4 +62,5 @@ while ($retry -lt $maxRetries) {
} }
Write-Host "`nWarning: Backend health check timed out. Check logs with:" -ForegroundColor Yellow Write-Host "`nWarning: Backend health check timed out. Check logs with:" -ForegroundColor Yellow
Write-Host " podman-compose -f compose/demo.yml logs backend" $composeArgsText = ($composeArgs -join ' ')
Write-Host " podman-compose $composeArgsText logs backend"

View file

@ -7,6 +7,14 @@ set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR/.." cd "$SCRIPT_DIR/.."
ENV_FILE="compose/.env.demo"
COMPOSE_ARGS=("-f" "compose/demo.yml")
if [ -f "$ENV_FILE" ]; then
COMPOSE_ARGS=("--env-file" "$ENV_FILE" "-f" "compose/demo.yml")
elif [ -f "compose/.env.demo.example" ]; then
COMPOSE_ARGS=("--env-file" "compose/.env.demo.example" "-f" "compose/demo.yml")
fi
echo "=== Likwid Demo Reset ===" echo "=== Likwid Demo Reset ==="
if [ "$1" != "--force" ] && [ "$1" != "-f" ]; then if [ "$1" != "--force" ] && [ "$1" != "-f" ]; then
@ -17,16 +25,13 @@ if [ "$1" != "--force" ] && [ "$1" != "-f" ]; then
fi fi
fi fi
echo -e "\n[1/4] Stopping demo containers..." echo -e "\n[1/3] Stopping demo containers and removing volumes..."
podman-compose -f compose/demo.yml down || docker-compose -f compose/demo.yml down podman-compose "${COMPOSE_ARGS[@]}" down --remove-orphans -v || docker-compose "${COMPOSE_ARGS[@]}" down --remove-orphans -v
echo -e "\n[2/4] Removing demo database volume..." echo -e "\n[2/3] Starting fresh demo instance..."
podman volume rm likwid_demo_data -f 2>/dev/null || docker volume rm likwid_demo_data -f 2>/dev/null || true podman-compose "${COMPOSE_ARGS[@]}" up -d || docker-compose "${COMPOSE_ARGS[@]}" up -d
echo -e "\n[3/4] Starting fresh demo instance..." echo -e "\n[3/3] Waiting for services to be ready..."
podman-compose -f compose/demo.yml up -d || docker-compose -f compose/demo.yml up -d
echo -e "\n[4/4] Waiting for services to be ready..."
sleep 5 sleep 5
max_retries=30 max_retries=30
@ -49,4 +54,5 @@ while [ $retry -lt $max_retries ]; do
done done
echo -e "\nWarning: Backend health check timed out. Check logs with:" echo -e "\nWarning: Backend health check timed out. Check logs with:"
echo " podman-compose -f compose/demo.yml logs backend" echo " podman-compose ${COMPOSE_ARGS[*]} logs backend"
echo " docker-compose ${COMPOSE_ARGS[*]} logs backend"

View file

@ -73,7 +73,7 @@ $backend = Start-Process -FilePath 'cmd.exe' `
# Start frontend # Start frontend
Write-Host "Starting frontend..." Write-Host "Starting frontend..."
$frontend = Start-Process -FilePath 'cmd.exe' ` $frontend = Start-Process -FilePath 'cmd.exe' `
-ArgumentList '/c', 'npm', 'run', 'dev', '2>&1' ` -ArgumentList '/c', "set PUBLIC_API_BASE=http://127.0.0.1:3000&& npm run dev", '2>&1' `
-WorkingDirectory (Join-Path $root 'frontend') ` -WorkingDirectory (Join-Path $root 'frontend') `
-PassThru -WindowStyle Hidden ` -PassThru -WindowStyle Hidden `
-RedirectStandardOutput $frontendLog -RedirectStandardOutput $frontendLog

View file

@ -50,7 +50,7 @@ BACKEND_PID=$!
# Start frontend # Start frontend
echo "Starting frontend..." echo "Starting frontend..."
cd "$ROOT_DIR/frontend" cd "$ROOT_DIR/frontend"
npm run dev > "$FRONTEND_LOG" 2>&1 & PUBLIC_API_BASE="http://127.0.0.1:3000" npm run dev > "$FRONTEND_LOG" 2>&1 &
FRONTEND_PID=$! FRONTEND_PID=$!
# Save state # Save state

View file

@ -7,7 +7,7 @@ Write-Host "=== Preparing Production Build ===" -ForegroundColor Cyan
$projectRoot = "$PSScriptRoot\.." $projectRoot = "$PSScriptRoot\.."
$backendDir = "$projectRoot\backend" $backendDir = "$projectRoot\backend"
$migrationsDir = "$backendDir\migrations" $migrationsDir = "$backendDir\migrations_demo"
$demoMigration = "$migrationsDir\20260127150000_demo_seed_data.sql" $demoMigration = "$migrationsDir\20260127150000_demo_seed_data.sql"
# Check if demo migration exists # Check if demo migration exists
@ -16,17 +16,11 @@ if (Test-Path $demoMigration) {
Write-Host " 1. This file should be EXCLUDED from production deployments" Write-Host " 1. This file should be EXCLUDED from production deployments"
Write-Host " 2. It contains test users and sample data" Write-Host " 2. It contains test users and sample data"
Write-Host "" Write-Host ""
$action = Read-Host "Remove demo migration for production build? (y/N)" Write-Host "No action required:" -ForegroundColor Green
if ($action -eq "y" -or $action -eq "Y") { Write-Host " - The backend only runs migrations_demo when DEMO_MODE=true"
# Backup first Write-Host " - The production container build excludes demo seed data via INCLUDE_DEMO_SEED=false"
$backupPath = "$demoMigration.backup" Write-Host " - Keep this file in your working tree for demo/dev" -ForegroundColor Green
Copy-Item $demoMigration $backupPath
Remove-Item $demoMigration
Write-Host "Demo migration removed (backup at $backupPath)" -ForegroundColor Green
} else {
Write-Host "Keeping demo migration. Remember to remove for production!" -ForegroundColor Yellow
}
} else { } else {
Write-Host "Demo migration not found - already production ready" -ForegroundColor Green Write-Host "Demo migration not found - already production ready" -ForegroundColor Green
} }