-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunner.ps1
executable file
·51 lines (41 loc) · 1.13 KB
/
runner.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
param(
[Parameter(Position=0)][string[]]$command,
[Parameter(ValueFromRemainingArguments)][string[]] $params,
[Alias("l")][string]$language,
[Alias("v")][string]$version,
[Alias("p")][string[]]$publish,
[Alias("e")][string[]]$enviroment
)
$WORKDIR="/src"
$MAKEFILEDIR="/make"
$repo_url="ghcr.io/byteford/runner"
$image="alpine"
function get_name{
Write-Output (($pwd.Path -replace "\\","") -replace ":","")
}
function start_container{
if ($publish -ne $null){
$pre = "-p"
}
$env = "--env " + $enviroment -join "--env "
echo $env
docker run -it --detach --rm --name $(get_name) $pre "$publish" --volume ${pwd}:$WORKDIR --env WORKDIR=$WORKDIR $env $image
}
function stop_container{
docker stop $(get_name)
}
switch($command){
"start"{
$image="$repo_url/runner-${language}:$version"
start_container
}
"stop"{
stop_container
}
"app"{
docker exec -it -w $WORKDIR $(get_name) $params
}
default {
docker exec -it -w $MAKEFILEDIR $(get_name) make PARAMS=$params $command
}
}