-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·53 lines (51 loc) · 1.32 KB
/
build.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
#!/bin/bash
# exit when any command fails
set -e
colors=("blue" "red" "green")
template="template.html"
# prompt the user for the docker image name if not set
if [[ -z $DOCKER_IMAGE_NAME ]]; then
read -p "Enter the docker image name: " DOCKER_IMAGE_NAME
fi
function build_apps() {
alt=$1
suffix="-alt"
if [[ -z $alt ]]; then
suffix=""
elif [[ -n $2 ]]; then
suffix=$2
fi
for i in "${!colors[@]}"; do
appNum=$((i + 1))
color=${colors[$i]}
echo "Building app$appNum with color $color"
export appNum color suffix alt
cat $template | envsubst >"index.html"
# set -x
docker buildx build --platform linux/arm64,linux/amd64 -t "$DOCKER_IMAGE_NAME:app$appNum$suffix" --push .
if [[ $appNum -eq 3 && -z $alt ]]; then
docker buildx build --platform linux/arm64,linux/amd64 -t "$DOCKER_IMAGE_NAME:1.0.2" --push .
fi
# set +x
done
rm index.html
}
function build_single_app() {
if [[ -z $VERSION ]]; then
read -p "Enter the version: " VERSION
fi
alt="version $VERSION"
color=gold
export alt color
cat $template | envsubst >"index.html"
docker buildx build --platform linux/arm64,linux/amd64 -t "$DOCKER_IMAGE_NAME:$VERSION" --push .
rm index.html
}
# if --single is passed, build only the first app
if [[ $1 == "--single" ]]; then
echo "Building only app1"
build_single_app
exit 0
fi
build_apps
build_apps " - Alt"