forked from prodrigestivill/docker-postgres-backup-local
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.sh
executable file
·84 lines (69 loc) · 1.8 KB
/
generate.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
#!/bin/sh
set -e
DOCKER_BAKE_FILE=${1:-"docker-bake.hcl"}
TAGS=${TAGS:-"13 12 11 10 9.6 9.5"}
GOCRONVER=${GOCRONVER:-"v0.0.10"}
PLATFORMS=${PLATFORMS:-"linux/amd64 linux/arm64 linux/arm/v7 linux/s390x linux/ppc64le"}
IMAGE_NAME=${IMAGE_NAME:-"prodrigestivill/postgres-backup-local"}
cd "$(dirname "$0")"
MAIN_TAG=${TAGS%%" "*} # First tag
TAGS_EXTRA=${TAGS#*" "} # Rest of tags
P="\"$(echo $PLATFORMS | sed 's/ /", "/g')\""
T="\"debian-latest\", \"alpine-latest\", \"$(echo debian-$TAGS_EXTRA | sed 's/ /", "debian-/g')\", \"$(echo alpine-$TAGS_EXTRA | sed 's/ /", "alpine-/g')\""
cat > "$DOCKER_BAKE_FILE" << EOF
group "default" {
targets = [$T]
}
variable "BUILDREV" {
default = ""
}
target "common" {
platforms = [$P]
args = {"GOCRONVER" = "$GOCRONVER"}
}
target "debian" {
inherits = ["common"]
dockerfile = "debian.Dockerfile"
}
target "alpine" {
inherits = ["common"]
dockerfile = "alpine.Dockerfile"
}
target "debian-latest" {
inherits = ["debian"]
args = {"BASETAG" = "$MAIN_TAG"}
tags = [
"$IMAGE_NAME:latest",
"$IMAGE_NAME:$MAIN_TAG",
notequal("", BUILDREV) ? "$IMAGE_NAME:$MAIN_TAG-debian-\${BUILDREV}" : ""
]
}
target "alpine-latest" {
inherits = ["alpine"]
args = {"BASETAG" = "$MAIN_TAG-alpine"}
tags = [
"$IMAGE_NAME:alpine",
"$IMAGE_NAME:$MAIN_TAG-alpine",
notequal("", BUILDREV) ? "$IMAGE_NAME:$MAIN_TAG-alpine-\${BUILDREV}" : ""
]
}
EOF
for TAG in $TAGS_EXTRA; do cat >> "$DOCKER_BAKE_FILE" << EOF
target "debian-$TAG" {
inherits = ["debian"]
args = {"BASETAG" = "$TAG"}
tags = [
"$IMAGE_NAME:$TAG",
notequal("", BUILDREV) ? "$IMAGE_NAME:$TAG-debian-\${BUILDREV}" : ""
]
}
target "alpine-$TAG" {
inherits = ["alpine"]
args = {"BASETAG" = "$TAG-alpine"}
tags = [
"$IMAGE_NAME:$TAG-alpine",
notequal("", BUILDREV) ? "$IMAGE_NAME:$TAG-alpine-\${BUILDREV}" : ""
]
}
EOF
done