Modules/businessdev.ALbuild.Apps/Private/Copy-BcFileToContainer.ps1
|
function Copy-BcFileToContainer { <# .SYNOPSIS Makes a host file available inside a container and returns its in-container path. .DESCRIPTION Internal helper. Writes the file into the host folder that New-BcContainer bind-mounts to C:\run\my, so it appears inside the container without 'docker cp' (which is unsupported against a running hyperv-isolated container). Returns the path the container sees the file at. .OUTPUTS System.String - the in-container path (C:\run\my\<file>). #> [CmdletBinding()] [OutputType([string])] param( [Parameter(Mandatory)] [string] $Name, [Parameter(Mandatory)] [string] $Source, [string] $DockerExecutable = 'docker' ) # Resolve the container's ACTUAL C:\run\my bind mount (a release/on-prem deploy targets a container # this job did not create, so the deterministic convention would point at the wrong host folder). $hostShare = Resolve-BcContainerHostShare -Name $Name -DockerExecutable $DockerExecutable if (-not (Test-Path -LiteralPath $hostShare)) { New-Item -ItemType Directory -Force -Path $hostShare | Out-Null } $leaf = Split-Path -Path $Source -Leaf Copy-Item -LiteralPath $Source -Destination (Join-Path $hostShare $leaf) -Force return "C:\run\my\$leaf" } |