Created
September 3, 2022 18:18
-
-
Save martinpurvis/c221edf5d9ffcc8edcc8115c7a57db36 to your computer and use it in GitHub Desktop.
apiman - windows docker files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
--[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