-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_and_run.ps1
More file actions
35 lines (29 loc) · 847 Bytes
/
build_and_run.ps1
File metadata and controls
35 lines (29 loc) · 847 Bytes
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
param(
[switch]$Push,
[switch]$Run,
[string]$Version = 'latest',
[string]$AppName = 'vcsim',
[string]$DockerHubUser = 'satak',
[string]$Folder = '.',
[int]$InternalPort = 443,
[int]$externalPort = 443
)
$tag = "$($DockerHubUser)/$($AppName):$($Version)"
docker kill $AppName
docker rm $AppName
docker rmi $AppName
docker build -t $tag $Folder
if ($Push) {
docker push $tag
}
if ($Run) {
docker run -it -d --name $appName -p "$($externalPort):$($internalPort)" $tag
}
# delete builder docker image
docker rmi $(docker images --filter "label=builder=true" -q)
Write-Output "`n"
Write-Output "To push the docker image run command:"
Write-Output "docker push $tag"
Write-Output "`n"
Write-Output "To run the container run command:"
Write-Output "docker run -it -d --name $appName -p '$($externalPort):$($internalPort)' $tag"