forked from prodrigestivill/docker-postgres-backup-local
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-docker-bake.sh
executable file
·116 lines (97 loc) · 2.78 KB
/
generate-docker-bake.sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
set -e
GOCRONVER="v0.0.10"
MAIN_TAG="14"
TAGS_EXTRA="13 12"
PLATFORMS="linux/amd64 linux/arm64 linux/arm/v7 linux/s390x linux/ppc64le"
TAGS_EXTRA_2="11 10"
PLATFORMS_DEBIAN_2="linux/amd64 linux/arm64 linux/arm/v7"
DOCKER_BAKE_FILE="docker-bake.hcl"
cd "$(dirname "$0")"
P="\"$(echo $PLATFORMS | sed 's/ /", "/g')\""
P2="\"$(echo $PLATFORMS_DEBIAN_2 | sed 's/ /", "/g')\""
T="\"debian-latest\", \"alpine-latest\", \"$(echo debian-$TAGS_EXTRA $TAGS_EXTRA_2 | sed 's/ /", "debian-/g')\", \"$(echo alpine-$TAGS_EXTRA $TAGS_EXTRA_2 | sed 's/ /", "alpine-/g')\""
cat > "$DOCKER_BAKE_FILE" << EOF
group "default" {
targets = [$T]
}
variable "REGISTRY_PREFIX" {
default = ""
}
variable "IMAGE_NAME" {
default = "postgres-backup-local"
}
variable "BUILD_REVISION" {
default = ""
}
target "debian" {
args = {"GOCRONVER" = "$GOCRONVER"}
dockerfile = "debian.Dockerfile"
}
target "alpine" {
args = {"GOCRONVER" = "$GOCRONVER"}
dockerfile = "alpine.Dockerfile"
}
target "debian-latest" {
inherits = ["debian"]
platforms = [$P]
args = {"BASETAG" = "$MAIN_TAG"}
tags = [
"\${REGISTRY_PREFIX}\${IMAGE_NAME}:latest",
"\${REGISTRY_PREFIX}\${IMAGE_NAME}:$MAIN_TAG",
notequal("", BUILD_REVISION) ? "\${REGISTRY_PREFIX}\${IMAGE_NAME}:$MAIN_TAG-debian-\${BUILD_REVISION}" : ""
]
}
target "alpine-latest" {
inherits = ["alpine"]
platforms = [$P]
args = {"BASETAG" = "$MAIN_TAG-alpine"}
tags = [
"\${REGISTRY_PREFIX}\${IMAGE_NAME}:alpine",
"\${REGISTRY_PREFIX}\${IMAGE_NAME}:$MAIN_TAG-alpine",
notequal("", BUILD_REVISION) ? "\${REGISTRY_PREFIX}\${IMAGE_NAME}:$MAIN_TAG-alpine-\${BUILD_REVISION}" : ""
]
}
EOF
for TAG in $TAGS_EXTRA; do cat >> "$DOCKER_BAKE_FILE" << EOF
target "debian-$TAG" {
inherits = ["debian"]
platforms = [$P]
args = {"BASETAG" = "$TAG"}
tags = [
"\${REGISTRY_PREFIX}\${IMAGE_NAME}:$TAG",
notequal("", BUILD_REVISION) ? "\${REGISTRY_PREFIX}\${IMAGE_NAME}:$TAG-debian-\${BUILD_REVISION}" : ""
]
}
target "alpine-$TAG" {
inherits = ["alpine"]
platforms = [$P]
args = {"BASETAG" = "$TAG-alpine"}
tags = [
"\${REGISTRY_PREFIX}\${IMAGE_NAME}:$TAG-alpine",
notequal("", BUILD_REVISION) ? "\${REGISTRY_PREFIX}\${IMAGE_NAME}:$TAG-alpine-\${BUILD_REVISION}" : ""
]
}
EOF
done
for TAG in $TAGS_EXTRA_2; do cat >> "$DOCKER_BAKE_FILE" << EOF
target "debian-$TAG" {
inherits = ["debian"]
platforms = [$P2]
args = {"BASETAG" = "$TAG"}
tags = [
"\${REGISTRY_PREFIX}\${IMAGE_NAME}:$TAG",
notequal("", BUILD_REVISION) ? "\${REGISTRY_PREFIX}\${IMAGE_NAME}:$TAG-debian-\${BUILD_REVISION}" : ""
]
}
target "alpine-$TAG" {
inherits = ["alpine"]
platforms = [$P]
args = {"BASETAG" = "$TAG-alpine"}
tags = [
"\${REGISTRY_PREFIX}\${IMAGE_NAME}:$TAG-alpine",
notequal("", BUILD_REVISION) ? "\${REGISTRY_PREFIX}\${IMAGE_NAME}:$TAG-alpine-\${BUILD_REVISION}" : ""
]
}
EOF
done