mirror of
https://codeberg.org/likwid/likwid.git
synced 2026-02-09 21:13:09 +00:00
scripts: improve demo reset and production prep
This commit is contained in:
parent
180fe5f05d
commit
f3a5edd91d
5 changed files with 38 additions and 31 deletions
|
|
@ -19,16 +19,22 @@ if (-not $Force) {
|
|||
|
||||
Set-Location "$PSScriptRoot\.."
|
||||
|
||||
Write-Host "`n[1/4] Stopping demo containers..." -ForegroundColor Yellow
|
||||
podman-compose -f compose/demo.yml down
|
||||
$envFile = "compose/.env.demo"
|
||||
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
|
||||
podman volume rm likwid_demo_data -f 2>$null
|
||||
Write-Host "`n[1/3] Stopping demo containers and removing volumes..." -ForegroundColor Yellow
|
||||
podman-compose @composeArgs down --remove-orphans -v
|
||||
|
||||
Write-Host "`n[3/4] Starting fresh demo instance..." -ForegroundColor Yellow
|
||||
podman-compose -f compose/demo.yml up -d
|
||||
Write-Host "`n[2/3] Starting fresh demo instance..." -ForegroundColor Yellow
|
||||
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
|
||||
|
||||
# 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 " podman-compose -f compose/demo.yml logs backend"
|
||||
$composeArgsText = ($composeArgs -join ' ')
|
||||
Write-Host " podman-compose $composeArgsText logs backend"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,14 @@ set -e
|
|||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
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 ==="
|
||||
|
||||
if [ "$1" != "--force" ] && [ "$1" != "-f" ]; then
|
||||
|
|
@ -17,16 +25,13 @@ if [ "$1" != "--force" ] && [ "$1" != "-f" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
echo -e "\n[1/4] Stopping demo containers..."
|
||||
podman-compose -f compose/demo.yml down || docker-compose -f compose/demo.yml down
|
||||
echo -e "\n[1/3] Stopping demo containers and removing volumes..."
|
||||
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..."
|
||||
podman volume rm likwid_demo_data -f 2>/dev/null || docker volume rm likwid_demo_data -f 2>/dev/null || true
|
||||
echo -e "\n[2/3] Starting fresh demo instance..."
|
||||
podman-compose "${COMPOSE_ARGS[@]}" up -d || docker-compose "${COMPOSE_ARGS[@]}" up -d
|
||||
|
||||
echo -e "\n[3/4] Starting fresh demo instance..."
|
||||
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..."
|
||||
echo -e "\n[3/3] Waiting for services to be ready..."
|
||||
sleep 5
|
||||
|
||||
max_retries=30
|
||||
|
|
@ -49,4 +54,5 @@ while [ $retry -lt $max_retries ]; do
|
|||
done
|
||||
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ $backend = Start-Process -FilePath 'cmd.exe' `
|
|||
# Start frontend
|
||||
Write-Host "Starting frontend..."
|
||||
$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') `
|
||||
-PassThru -WindowStyle Hidden `
|
||||
-RedirectStandardOutput $frontendLog
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ BACKEND_PID=$!
|
|||
# Start frontend
|
||||
echo "Starting 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=$!
|
||||
|
||||
# Save state
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Write-Host "=== Preparing Production Build ===" -ForegroundColor Cyan
|
|||
|
||||
$projectRoot = "$PSScriptRoot\.."
|
||||
$backendDir = "$projectRoot\backend"
|
||||
$migrationsDir = "$backendDir\migrations"
|
||||
$migrationsDir = "$backendDir\migrations_demo"
|
||||
$demoMigration = "$migrationsDir\20260127150000_demo_seed_data.sql"
|
||||
|
||||
# Check if demo migration exists
|
||||
|
|
@ -17,16 +17,10 @@ if (Test-Path $demoMigration) {
|
|||
Write-Host " 2. It contains test users and sample data"
|
||||
Write-Host ""
|
||||
|
||||
$action = Read-Host "Remove demo migration for production build? (y/N)"
|
||||
if ($action -eq "y" -or $action -eq "Y") {
|
||||
# Backup first
|
||||
$backupPath = "$demoMigration.backup"
|
||||
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
|
||||
}
|
||||
Write-Host "No action required:" -ForegroundColor Green
|
||||
Write-Host " - The backend only runs migrations_demo when DEMO_MODE=true"
|
||||
Write-Host " - The production container build excludes demo seed data via INCLUDE_DEMO_SEED=false"
|
||||
Write-Host " - Keep this file in your working tree for demo/dev" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Demo migration not found - already production ready" -ForegroundColor Green
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue