-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.ps1
43 lines (34 loc) · 922 Bytes
/
build.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
$ErrorActionPreference = "Stop"
$ARCHITECTURE = "$($args[0])"
$OS = "$($args[1])"
$HUB_ORG = "$($args[2])"
$IMAGE_NAME = "$($args[3])"
$TAG = "master"
$HUB_IMAGE = "${HUB_ORG}/${IMAGE_NAME}:${TAG}"
Function check_input() {
if (-not $ARCHITECTURE) {
Throw "Missing input parameter ARCHITECTURE"
}
if (-not $OS) {
Throw "Missing input parameter OS"
}
if (-not $HUB_ORG) {
Throw "Missing input parameter HUB_ORG"
}
if (-not $IMAGE_NAME) {
Throw "Missing input parameter HUB_ORG"
}
}
Function set_build_context() {
(Get-Content ./image/$ARCHITECTURE/$OS/Dockerfile) -replace '{{%TAG%}}', "$TAG" | Set-Content ./image/$ARCHITECTURE/$OS/Dockerfile
}
Function build_and_tag_image() {
docker build --no-cache -f ./image/$ARCHITECTURE/$OS/Dockerfile -t "$HUB_IMAGE" .
}
Function push_images() {
docker push "$HUB_IMAGE"
}
check_input
set_build_context
build_and_tag_image
push_images