-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·69 lines (57 loc) · 1.7 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
#Variables
DOCKERFILE="Dockerfile"
# Functions
instructions_front () {
echo "---- Frontend build (first arg) : ----"
echo ">>>Use : './build.sh --localAngular | -la‘ To build the frontend locally"
echo ">>>Use : './build.sh --dockerAngular | -dr' To build the frontend in the dockerfile"
}
instructions_image () {
echo "---- Image build (second arg) : ----"
echo ">>>Use : \'./build.sh --active | -a\‘ To build the image for local achitecture only"
echo ">>>Use : \'./build.sh --multi | -m\' To build the image for amd64/arm64/armv7 achitectures"
}
#START SCRIPT
# check if arguments are given
if [ $# -lt '2' ];
then
echo ">>>No Argument specified !!"
instructions_front
instructions_image
exit 1
fi
# check if frontend is to be build locolly or in the dockerfile
if [ $1 = '--localAngular' ] || [ $1 = '-la' ];
then
echo ">>>Build Frontend locally"
cd chatapp-front/
npm install
ng build --configuration=production
cd ..
DOCKERFILE='Dockerfile.noAngular'
elif [ $1 = '--dockerAngular' ] || [ $1 = '-dr' ];
then
echo ">>>Build Frontend in Docker"
else
echo ">>>No Frontend builded !!"
instructions_front
exit 1
fi
# Build Docker Image
if [ $2 = '--multi' ] || [ $2 = '-m' ];
then
echo "Build for Multi-Arch"
#Build for Multi-Arch
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louvandtech/chat-app --push -f $DOCKERFILE .
elif [ $2 = '--active' ] || [ $2 = '-a' ];
then
echo "Build for active Arch"
#Build for active Arch
docker build --tag louvandtech/chat-app -f $DOCKERFILE .
else
echo ">>>No Arch specified !!"
instructions_image
exit 1
fi
echo ">>>Compliation Done !"