forked from prodrigestivill/docker-postgres-backup-local
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.sh
executable file
·66 lines (52 loc) · 1.43 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
#!/bin/sh
set -e
DOCKER_BAKE_FILE=${1:-"docker-bake.hcl"}
TAGS=${TAGS:-"12 11 10 9.6 9.5 9.4"}
GOCRONVER=${GOCRONVER:-"v0.0.9"}
PLATFORMS=${PLATFORMS:-"linux/amd64 linux/arm64 linux/arm/v7"}
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]
}
target "common" {
platforms = [$P]
args = {"GOCRONVER" = "$GOCRONVER"}
}
target "debian" {
inherits = ["common"]
dockerfile = "Dockerfile-debian"
}
target "alpine" {
inherits = ["common"]
dockerfile = "Dockerfile-alpine"
}
target "debian-latest" {
inherits = ["debian"]
args = {"BASETAG" = "$MAIN_TAG"}
tags = ["$IMAGE_NAME:latest", "$IMAGE_NAME:$MAIN_TAG"]
}
target "alpine-latest" {
inherits = ["alpine"]
args = {"BASETAG" = "$MAIN_TAG-alpine"}
tags = ["$IMAGE_NAME:alpine", "$IMAGE_NAME:$MAIN_TAG-alpine"]
}
EOF
for TAG in $TAGS_EXTRA; do cat >> "$DOCKER_BAKE_FILE" << EOF
target "debian-$TAG" {
inherits = ["debian"]
args = {"BASETAG" = "$TAG"}
tags = ["$IMAGE_NAME:$TAG"]
}
target "alpine-$TAG" {
inherits = ["alpine"]
args = {"BASETAG" = "$TAG-alpine"}
tags = ["$IMAGE_NAME:$TAG-alpine"]
}
EOF
done