-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-all.sh
executable file
·118 lines (92 loc) · 2.33 KB
/
build-all.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
set -e
cd $(dirname $0) # work in our own turf.
OUTPUT_DIR=www
print_help()
{
cat 1>&2 <<EOF
build-all Usage:
build-all [opts]
-o - Build Output Directory
-h - Print this message
EOF
}
##
## some fancy options
##
while getopts ":h:o:e:x:i:d" opt;do
case $opt in
# o) # speciy the output directory
# OUTPUT_DIR=`realpath ${OPTARG}`
# ;;
e) # environment file
ENV_FILE=`realpath ${OPTARG}`
`cat $ENV_FILE | grep = | sed -e "s/^/export /g"`
;;
x) # environment url
if [ echo $OPTARG | grep -E "^http" ]; then
curl $OPTARG | source
fi
;;
d) # environment url
DEPLOY=true
;;
# i)
# CLIENT_DIR=${OPTARG}
# [ -e $CLIENT_DIR ] || (echo "-o must point to ./client/src" >&2; exit 1)
# ;;
\?)
echo "Invalid arguements" >&2
print_help
exit 1
;;
:)
echo "Option -${OPTARG} requires arguement." >&2
print_help
exit 1
;;
esac
echo $opt
done
shift $((OPTIND-1))
mkdir -p $OUTPUT_DIR;
echo "Output Directory: $OUTPUT_DIR"
##
## build client
##
cd client
npm install --log-level=warn
./scripts/lint-elements.sh src/components/*
./scripts/deku-wrap.sh
browserify -v -d src/app.js -t babelify -t envify -o ../$OUTPUT_DIR/app.js
echo "created ../$OUTPUT_DIR/app.js"
myth src/styles/app.css ../$OUTPUT_DIR/app.css
echo "created ../$OUTPUT_DIR/app.css"
echo "copying pages, images, libs n' shit."
cp -vru src/public/* ../$OUTPUT_DIR/
cd -
# mochify --transform babelify --reporter spec ./test/index.js
# echo 'no tests passed, but if there were some.. they might'
##
##
## build server
##
cd server
npm install --log-level=warn
cd -
if [[ $DEPLOY ]]; then
docker build -t klouds-all - <<KEOF
FROM node
RUN npm install -g babel http-server
EXPOSE 8080
CMD bash
KEOF
docker run -d --name=redis redis || docker start redis
# docker run -d -p 9000:${WWW_PORT} klouds-all http-server www -p ${WWW_PORT}
# docker run -d -p 8000:${API_PORT} klouds-all babel-node server/main.js
cid=`docker run -d klouds-all`
docker cp . $cid:/klouds
docker commit $cid klouds-all
docker run -d --env-file="$ENV_FILE" -p 80:8080 klouds-all http-server /klouds/www
docker run -d --env-file="$ENV_FILE" --workdir=/klouds/server --link=redis:redis -p 8080:8080 klouds-all babel-node main.js
fi