|
| 1 | +# ===================================================== |
| 2 | +# 🚀 QRShop Remote Launcher (Always Pull Latest) |
| 3 | +# ===================================================== |
| 4 | + |
| 5 | +# ----------------------------------------------------- |
| 6 | +# Parameters (optional) |
| 7 | +# ----------------------------------------------------- |
| 8 | +param( |
| 9 | + [string]$StripeSecretKey = "", |
| 10 | + [string]$StripePublishableKey = "" |
| 11 | +) |
| 12 | + |
| 13 | +# ----------------------------------------------------- |
| 14 | +# Constants |
| 15 | +# ----------------------------------------------------- |
| 16 | +$COMPOSE_URL = "https://raw.githubusercontent.com/dlopes-se/dotnet-qrshop/main/docker-compose.demo.yml" |
| 17 | + |
| 18 | +Write-Host "" |
| 19 | +Write-Host "🧩 QRShop setup starting..." |
| 20 | +Write-Host "" |
| 21 | + |
| 22 | +# ----------------------------------------------------- |
| 23 | +# 🧠 Check dependencies |
| 24 | +# ----------------------------------------------------- |
| 25 | +function Check-Command { |
| 26 | + param([string]$Cmd, [string]$Name) |
| 27 | + if (-not (Get-Command $Cmd -ErrorAction SilentlyContinue)) { |
| 28 | + Write-Error "❌ Error: $Name is not installed." |
| 29 | + Write-Host "👉 Please install it first and try again." |
| 30 | + exit 1 |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +Check-Command -Cmd "docker" -Name "Docker" |
| 35 | + |
| 36 | +try { |
| 37 | + docker compose version | Out-Null |
| 38 | +} catch { |
| 39 | + Write-Error "❌ Error: Docker Compose v2 is not available." |
| 40 | + Write-Host "👉 Please ensure your Docker version supports 'docker compose'." |
| 41 | + exit 1 |
| 42 | +} |
| 43 | + |
| 44 | +Write-Host "✅ Docker and Compose detected." |
| 45 | +Write-Host "" |
| 46 | + |
| 47 | +# ----------------------------------------------------- |
| 48 | +# 💳 Ask for optional Stripe backend secret if not provided |
| 49 | +# ----------------------------------------------------- |
| 50 | +if (-not $StripeSecretKey) { |
| 51 | + $StripeSecretKey = Read-Host "💳 Enter Stripe Secret Key (backend, optional, press Enter to skip)" |
| 52 | +} |
| 53 | + |
| 54 | +# 💳 Ask for optional Next.js Stripe publishable key if not provided |
| 55 | +if (-not $StripePublishableKey) { |
| 56 | + $StripePublishableKey = Read-Host "💳 Enter Stripe Publishable Key (frontend, optional, press Enter to skip)" |
| 57 | +} |
| 58 | + |
| 59 | +# ----------------------------------------------------- |
| 60 | +# 🧱 Download docker-compose.yml |
| 61 | +# ----------------------------------------------------- |
| 62 | +$tmpComposeFile = [System.IO.Path]::GetTempFileName() |
| 63 | +Invoke-WebRequest -Uri $COMPOSE_URL -OutFile $tmpComposeFile |
| 64 | + |
| 65 | +# ----------------------------------------------------- |
| 66 | +# 🐳 Pull and start containers |
| 67 | +# ----------------------------------------------------- |
| 68 | +Write-Host "" |
| 69 | +Write-Host "🐳 Pulling latest images and starting containers..." |
| 70 | +Write-Host "" |
| 71 | + |
| 72 | +# Set environment variables for Docker Compose |
| 73 | +$env:STRIPE_SECRET_KEY = $StripeSecretKey |
| 74 | +$env:NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY = $StripePublishableKey |
| 75 | + |
| 76 | +try { |
| 77 | + # Pull latest images |
| 78 | + docker compose -f $tmpComposeFile pull |
| 79 | + |
| 80 | + # Start containers |
| 81 | + docker compose -f $tmpComposeFile up -d |
| 82 | +} catch { |
| 83 | + Write-Error "❌ Docker Compose failed. QRShop is NOT running." |
| 84 | + Remove-Item $tmpComposeFile |
| 85 | + exit 1 |
| 86 | +} |
| 87 | + |
| 88 | +# ----------------------------------------------------- |
| 89 | +# 🧹 Cleanup |
| 90 | +# ----------------------------------------------------- |
| 91 | +Remove-Item $tmpComposeFile |
| 92 | + |
| 93 | +# ----------------------------------------------------- |
| 94 | +# ✅ Success |
| 95 | +# ----------------------------------------------------- |
| 96 | +Write-Host "" |
| 97 | +Write-Host "✅ QRShop is up and running!" |
| 98 | +Write-Host "👉 Frontend: http://localhost:3000" |
| 99 | +Write-Host "👉 Backend API: http://localhost:5000" |
| 100 | +Write-Host "" |
0 commit comments