-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
99 lines (85 loc) · 2.3 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
echo "Cheking meteor project..."
secs=$((3))
while [ $secs -gt 0 ]; do
echo -ne "$secs\033[0K\r"
sleep 1
: $((secs--))
done
if ! [ -d .meteor ]
then
echo "============================="
echo "This is not a meteor project!"
echo "============================="
else
echo "======================="
echo "This is meteor project!"
echo "======================="
while [[ $username == '' ]]
do
read -p "Docker username:" username
if [[ -z "$username" ]]; then
echo "No input. Try again!"
else
echo $username
fi
done
while [[ $name == '' ]]
do
read -p "Name for docker image:" name
if [[ -z "$name" ]]; then
echo "No input. Try again!"
else
echo $name
fi
done
read -p "Tag: (latest)?" tag
tag=${tag:-latest}
echo $tag
currentFolder="${PWD##*/}"
build_folder="$currentFolder-build"
if [ ! -d "../$build_folder" ]; then
mkdir -p "../$build_folder";
fi
echo "=========================="
echo "Building meteor project..."
echo "=========================="
secs=$((3))
while [ $secs -gt 0 ]; do
echo -ne "$secs\033[0K\r"
sleep 1
: $((secs--))
done
meteor build --architecture=os.linux.x86_64 "../$build_folder"
cd ../$build_folder
tar -xvzf "$currentFolder.tar.gz"
cd bundle
dockerfile=Dockerfile
if [ ! -e $dockerfile ]; then
echo "FROM node:4.4.7-slim
COPY . /bundle
RUN (cd /bundle/programs/server && npm install)
ENV PORT=80
EXPOSE 80
CMD node /bundle/main.js" > $dockerfile
fi
if [ -e $dockerfile ]; then
echo "=============="
echo "Dockerizing..."
echo "=============="
secs=$((3))
while [ $secs -gt 0 ]; do
echo -ne "$secs\033[0K\r"
sleep 1
: $((secs--))
done
docker build -t "$username/$name:$tag" .
else
echo "File $dockerfile does not exist!"
fi
echo "====================================================="
echo "Meteor project is successfully builded and dockerized"
echo "Builded meteor project is in folder $currentFolder-build"
echo "New docker image: $username/$name:$tag"
echo "====================================================="
fi