PowerShell_Scripts/dcup.ps1

20 lines
798 B
PowerShell

[CmdletBinding(SupportsShouldProcess)]param(
[string[]]$ProjectPath=@($PWD),
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
[string[]]$CliParams
)
$local:dcParams = [string]::Empty
if( $CliParams ) {
$dcParams = $CliParams | ForEach-Object {
if( $_ -match "(?:^'[^']+'$)|(?:^`"[^`"]+`"$)|(?:^[^\s]+$)" ) { $_ }
else { "'$($_.Replace( "'", "''" ))'" }
}
}
$ProjectPath | ForEach-Object {
$local:dcPath = $(Resolve-Path $(Join-Path $_ docker-compose.yml))
Write-Verbose "docker-compose --file $dcPath up -d --remove-orphans $dcParams && docker-compose --file $dcPath logs --follow --tail 10 $dcParams"
docker-compose --file $dcPath up -d --remove-orphans $dcParams && docker-compose --file $dcPath logs --follow --tail 10 $dcParams
}