Spaces:
Sleeping
Sleeping
File size: 3,188 Bytes
dd87944 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | # Fly.io deploy — une commande après ajout carte bancaire sur fly.io/billing
# Usage: powershell -ExecutionPolicy Bypass -File scripts\deploy-fly.ps1
$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
$EnvFile = Join-Path $Root "emo\backend\.env"
$FlyApp = "emo-online-xeroxytb"
$FlyUrl = "https://emo-online-xeroxytb.fly.dev"
$FlyBin = Join-Path $env:USERPROFILE ".fly\bin\flyctl.exe"
Write-Host ""
Write-Host "=== Emo Online - Deploy Fly.io 24/7 ===" -ForegroundColor Cyan
if (-not (Test-Path $FlyBin)) {
iwr https://fly.io/install.ps1 -useb | iex
}
if (-not (Test-Path $EnvFile)) {
Write-Host ".env introuvable" -ForegroundColor Red
exit 1
}
function Get-EnvValue($key) {
foreach ($line in Get-Content $EnvFile) {
if ($line -match "^\s*$key=(.*)$") {
$val = $Matches[1].Trim()
if ($val.StartsWith('"') -and $val.EndsWith('"')) { $val = $val.Substring(1, $val.Length - 2) }
return $val
}
}
return ""
}
$SecretKeys = @(
"MONGO_URL", "DB_NAME", "GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET",
"OPENAI_API_KEY", "ANTHROPIC_API_KEY", "GEMINI_API_KEY", "GROQ_API_KEY",
"OPENROUTER_API_KEY", "DEEPSEEK_API_KEY", "HF_TOKEN", "HUGGINGFACE_API_KEY",
"EMERGENT_LLM_KEY", "STRIPE_API_KEY", "STRIPE_BASIC_LINK", "STRIPE_PREMIUM_LINK",
"STRIPE_ULTRA_LINK", "EMO_ADMIN_EMAILS", "EMO_PRODUCT_KEYS", "EMO_USE_SALES_LLM_KEYS"
)
$DupMap = @{
"SALES_OPENAI_API_KEY" = "OPENAI_API_KEY"
"SALES_ANTHROPIC_API_KEY" = "ANTHROPIC_API_KEY"
"SALES_GEMINI_API_KEY" = "GEMINI_API_KEY"
"SALES_GROQ_API_KEY" = "GROQ_API_KEY"
"SALES_OPENROUTER_API_KEY" = "OPENROUTER_API_KEY"
"SALES_DEEPSEEK_API_KEY" = "DEEPSEEK_API_KEY"
"SALES_HF_TOKEN" = "HF_TOKEN"
}
$FlyEnv = @{
"EMO_PUBLIC_BACKEND_URL" = $FlyUrl
"EMO_FRONTEND_URL" = "https://xeroxytb.com"
"CORS_ORIGINS" = "https://xeroxytb.com,https://www.xeroxytb.com,https://xeroxytb.github.io"
"GOOGLE_REDIRECT_URI" = "$FlyUrl/api/auth/google/callback"
"EMO_SERVE_FRONTEND" = "false"
"EMO_DEV_MODE" = "false"
"EMO_USE_SALES_LLM_KEYS" = "true"
"PORT" = "8010"
}
Push-Location $Root
try {
$apps = & $FlyBin apps list 2>&1 | Out-String
if ($apps -notmatch $FlyApp) {
& $FlyBin apps create $FlyApp --org personal
}
$pairs = New-Object System.Collections.Generic.List[string]
foreach ($k in $SecretKeys) {
$v = Get-EnvValue $k
if ($v) { [void]$pairs.Add("${k}=$v") }
}
foreach ($sales in $DupMap.Keys) {
if (-not (Get-EnvValue $sales)) {
$src = Get-EnvValue $DupMap[$sales]
if ($src) { [void]$pairs.Add("${sales}=$src") }
}
}
foreach ($ek in $FlyEnv.Keys) {
[void]$pairs.Add("${ek}=$($FlyEnv[$ek])")
}
Write-Host "Secrets: $($pairs.Count)" -ForegroundColor Cyan
& $FlyBin secrets set $pairs.ToArray() --app $FlyApp
& $FlyBin deploy --app $FlyApp --ha=false
Write-Host "OK: $FlyUrl" -ForegroundColor Green
Write-Host "Google redirect: $FlyUrl/api/auth/google/callback" -ForegroundColor Yellow
}
finally {
Pop-Location
}
|