-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·55 lines (45 loc) · 1.29 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
echo "Create docker image for print api";
DOCKERHOST="ambersive"
IMAGENAME="print-api"
root="$(pwd)"
if [[ $root == */fastlane ]] ;
then
BUILD=$(cat $root/../package.json \
| grep versionNumber \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
PACKAGE_VERSION=$(cat $root/../package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
else
BUILD=$(cat $root/package.json \
| grep versionNumber \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
PACKAGE_VERSION=$(cat $root/package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
fi
LATEST="${DOCKERHOST}/${IMAGENAME}:latest"
COMPLETE="${DOCKERHOST}/${IMAGENAME}:${PACKAGE_VERSION}"
arg1="$1"
if [[ "$(docker images -q ${COMPLETE} 2> /dev/null)" == "" ]]; then
echo "Docker image for ${COMPLETE} does not exists on this maschine. Start creating it...";
docker build -f "$root/Dockerfile" -t ${COMPLETE} "${root}";
docker push $COMPLETE;
fi
docker build -f "$root/Dockerfile" -t ${LATEST} "${root}";
docker push $LATEST;
if [[ "${arg1}" == "--dev" ]]; then
docker-compose -f $root/docker-compose.yml up -d
fi