134 lines
3.1 KiB
PowerShell
134 lines
3.1 KiB
PowerShell
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:
|
|
"@
|
|
|
|
|
|
function IsInstalled-Docker {
|
|
$output = docker --version
|
|
|
|
return $output.StartsWith("Docker version");
|
|
}
|
|
|
|
function InstallDocker-Redos {
|
|
dnf install docker-ce docker-ce-cli docker-compose
|
|
}
|
|
|
|
#
|
|
# Скрипт для создания compose.yml файла ЛЭРС
|
|
#
|
|
|
|
|
|
$osRelease = Get-Content /etc/os-release | ConvertFrom-StringData
|
|
|
|
# Проверяем установлен ли Docker
|
|
|
|
if (Get-Command "docker" -ErrorAction SilentlyContinue) {
|
|
Write-Host "Docker установлен."
|
|
}
|
|
else {
|
|
if ( $osRelease.ID -eq "`"redos`"" ) {
|
|
InstallDocker-Redos
|
|
} else {
|
|
Write-Host "Docker не установлен. Установите Docker для вашей операционной системы $($osRelease.NAME)"
|
|
exit 1;
|
|
}
|
|
}
|
|
|
|
# Сохраняем compose файл для нужных опций
|
|
|
|
$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
|