Skip to content

Instantly share code, notes, and snippets.

@martinpurvis
Created September 3, 2022 18:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinpurvis/c221edf5d9ffcc8edcc8115c7a57db36 to your computer and use it in GitHub Desktop.
Save martinpurvis/c221edf5d9ffcc8edcc8115c7a57db36 to your computer and use it in GitHub Desktop.
apiman - windows docker files
<#
--[set-windows-dockerfiles.ps1]--
# for running apiman on a windows system
brief:
- Sets absolute paths in the compose files to the current working directory, maintaining unix line endings.
- Do this before running docker compose up commands
instructions:
- Copy this file to the apiman directory containing the docker compose files
- Open PowerShell and cd to the same directory
- Run the two below commands to properly format the compose files on Windows systems
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
.\set-windows-dockerfiles.ps1
#>
$filenames = ".\docker-compose.yml", ".\docker-compose.setup.yml"
foreach($filename in $filenames)
{
$file = gc $filename
$ln = ($file | Select-string -Pattern "PWD").LineNumber
$tmp = @()
for($i = 0; $i -lt $file.Length; $i++)
{
if($ln -contains ($i + 1))
{
$pwdWithForwardSlashes = ($PWD.Path).Replace("\","/")
$tmp += ($file)[$i].Replace("`$PWD",$pwdWithForwardSlashes)
}
else
{
$tmp += $file[$i]
}
}
$tmp | Out-File $filename
$txt = [io.file]::ReadAllText((gci $filename).FullName) -replace "`r`n","`n"
[io.file]::WriteAllText((gci $filename).FullName, $txt)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment