Initial commit

This commit is contained in:
Антон Чичков 2024-06-05 10:36:28 +10:00
commit 668bc135dd

98
Install-Lers.ps1 Normal file
View File

@ -0,0 +1,98 @@
param ([string]$db)
Set-Strictmode -Version 1
$composeDir = "."
$composeWithoutDb=@"
version: "3.9"
services:
lers:
image: sc.lers.ru/reg/full:`${VERSION:-latest}
ports:
- "10000:10000"
volumes:
- lers-data:/var/LERS
- lers-config-data:/etc/LERS
volumes:
lers-data:
lers-config-data:
"@
$composeSqlServer=@"
version: "3.9"
services:
lers:
image: sc.lers.ru/reg/full:`${VERSION:-latest}
depends_on:
- "db"
ports:
- "10000:10000"
volumes:
- lers-data:/var/LERS
environment:
LERS_SERVER_DATABASE__ConnectionString: "Data Source=db; Initial Catalog=LERS; User ID=sa; Password=`${DB_PASSWORD}; Integrated Security=false"
db:
image: "mcr.microsoft.com/mssql/server"
environment:
MSSQL_SA_PASSWORD: `${DB_PASSWORD}
ACCEPT_EULA: "y"
volumes:
- db-data:/var/opt/mssql/data
volumes:
lers-db-data:
lers-data:
"@
$composePostgres=@"
version: "3.9"
services:
lers:
image: lersamr/full:`${VERSION:-latest}
depends_on:
- "db"
ports:
- "10000:10000"
volumes:
- lers-data:/var/LERS
environment:
LERS_SERVER_DATABASE__ConnectionString: "Host=db;Database=LERS;Username=postgres;Password=${DB_PASSWORD}"
LERS_SERVER_DATABASE__Provider: "Postgres"
db:
image: postgres
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- lers-db-data:/var/lib/postgresql/data
volumes:
lers-db-data:
lers-data:
"@
$compose = $composeWithoutDb
if (($db -eq "pg") -or ($db -eq "postgres") -or ($db -eq "postgresql")) {
Write-Host "Устанавливается Postgres"
$compose = $composePostgres
}
elseif (($db -eq "sql") -or ($db -eq "sqlserver") -or ($db -eq "mssql") -or ($db -eq "mssqlserver")) {
Write-Host "Устанавливается Microsoft SQL Server"
$compose = $composeSqlServer
}
elseif ($db -eq "") {
Write-Host "Устанавливается система без базы данных"
}
else {
throw Error("Неподдерживаемая БД: " + $db)
}
# Создаём compose.yml
Out-File -FilePath "$composeDir/compose.yml" -InputObject $compose
# Создаём переменные среды
$envVars = @"
DB_PASSWORD=StrongDb_Password1
"@
Out-File -FilePath "$composeDir/.env" -InputObject $envVars