-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart.ps1
More file actions
39 lines (30 loc) · 1.55 KB
/
start.ps1
File metadata and controls
39 lines (30 loc) · 1.55 KB
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
<#
.SYNOPSIS
Start-Skript für das Projekt. Richtet automatisch die .env-Datei ein, falls sie fehlt.
#>
$envFile = ".env"
$envExampleFile = ".env.example"
if (-not (Test-Path $envFile)) {
Write-Host "Keine .env Datei gefunden. Erstelle eine neue aus $envExampleFile..." -ForegroundColor Yellow
if (-not (Test-Path $envExampleFile)) {
Write-Host "Fehler: Die Datei $envExampleFile existiert nicht!" -ForegroundColor Red
exit 1
}
Copy-Item $envExampleFile $envFile
# Generate random passwords/keys
$randomBytes = [byte[]]::new(32)
[System.Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($randomBytes)
$postgresPassword = [System.Convert]::ToBase64String($randomBytes) -replace '[^a-zA-Z0-9]', ''
[System.Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($randomBytes)
$djangoKey = [System.Convert]::ToBase64String($randomBytes) -replace '[^a-zA-Z0-9]', ''
# Replace values in the newly created .env
$envContent = Get-Content $envFile
$envContent = $envContent -replace 'POSTGRES_PASSWORD=.*', "POSTGRES_PASSWORD=$postgresPassword"
$envContent = $envContent -replace 'SECRET_KEY=.*', "SECRET_KEY='$djangoKey'"
$envContent | Set-Content $envFile
Write-Host "✅ .env erfolgreich erstellt und mit sicheren Schlüsseln befüllt." -ForegroundColor Green
} else {
Write-Host ".env Datei existiert bereits. Überspringe Generierung." -ForegroundColor Cyan
}
Write-Host "Starte Docker Container..." -ForegroundColor Cyan
docker compose up -d --build