-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-util.ps1
53 lines (44 loc) · 1.26 KB
/
docker-util.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
52
53
# SPDX-FileCopyrightText: Copyright Corsinvest Srl
# SPDX-License-Identifier: AGPL-3.0-only
param(
[Parameter(Mandatory=$true)]
[ValidateSet('test','build')]
[System.String]$operation
)
#read project version
$xml = [xml](Get-Content .\src\common.props)
$version = $xml.Project.PropertyGroup[0].Version
Write-Host "Project version: $version"
Write-Host "Operation: $operation "
function Build-Docker()
{
#apphero
Write-Host "Build Docker cv4net-apphero"
docker rmi corsinvest/cv4net-apphero:$version --force
docker build --rm -f "Dockerfile" -t corsinvest/cv4net-apphero:$version "."
#remove unused images
docker image prune -f
}
function Test-Docker()
{
New-Item -Path "d:\DockerData\cv4net-apphero\data" -ItemType "directory"
if (!(Test-Path "d:\DockerData\cv4net-apphero\appsettings.json"))
{
Copy-Item "src\Corsinvest.AppHero.AppBss\appsettings.json" -Destination "d:\DockerData\cv4net-apphero\appsettings.json"
}
docker run --rm -it `
-p 5000:80 `
-e TZ=Europe/Rome `
-v d:/DockerData/cv4net-apphero/data:/app/data `
-v d:/DockerData/cv4net-apphero/appsettings.json:/app/appsettings.json `
--name cv4net-apphero `
corsinvest/cv4net-apphero:$version
}
if($operation -eq 'test')
{
Test-Docker
}
elseif($operation -eq 'build')
{
Build-Docker
}