Skip to content

Commit

Permalink
use GUID for image name
Browse files Browse the repository at this point in the history
  • Loading branch information
nzbr committed Nov 10, 2022
1 parent 3bcd5ba commit 8b44d65
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/lib/lib_linux.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
function WSL-Install() {
$id = [guid]::NewGuid().ToString()

# Build docker image from the provided tarball
$tmpdir = $(mktemp -d)
Copy-Item $PSScriptRoot/Dockerfile $tmpdir
Copy-Item nixos-wsl-installer.tar.gz $tmpdir
docker build -t local:nixos-wsl $tmpdir | Write-Host
docker build -t nixos-wsl:$id $tmpdir | Write-Host
Remove-Item $tmpdir -Recurse -Force

# Spawn a new docker container
$id = docker run -di --privileged --init local:nixos-wsl /bin/sh
docker run -di --privileged --init --name $id nixos-wsl:$id /bin/sh
if ($LASTEXITCODE -ne 0) {
throw "Failed to launch docker container"
throw "Failed to launch container"
}

return $id
Expand All @@ -22,6 +24,10 @@ function WSL-Launch([string]$id, [string]$command) {
function WSL-Uninstall([string]$id) {
docker rm -f $id
if ($LASTEXITCODE -ne 0) {
throw "Failed to remove docker container"
throw "Failed to remove container"
}
docker rmi nixos-wsl:$id
if ($LASTEXITCODE -ne 0) {
throw "Failed to remove image"
}
}

0 comments on commit 8b44d65

Please sign in to comment.