-
Notifications
You must be signed in to change notification settings - Fork 14
/
run_dev.sh
executable file
·132 lines (116 loc) · 3.45 KB
/
run_dev.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/sh
##
# This script manages using a docker container for local development
# See the "Docker" section of README.md for more information
##
noParams=false
stopAtEnd=false
if [ $# -eq 0 ]
then
echo "No parameters provided, running '(start) install build test serve'"
noParams=true
fi
# Functions to start and stop the docker container
start () {
echo "----- Stopping Container (if exists)"
stop
echo "----- Building Container"
docker build -t history-project .
echo "----- Starting Container"
docker run -itd \
--name="history-project" \
-p=8000:8000 \
-v "$(pwd)":/home/travis/newtheatre/history-project \
history-project \
tail -f /dev/null
}
stop () {
echo "----- Stopping history-project container"
docker stop -t=0 history-project
echo "----- Destroying history-project container"
docker rm history-project
}
# Script fragments to be assembled and sent to the container
script="echo '----- RSyncing repo into linux filesystem' &&\
rsync -Pa --delete \
--exclude '.bundle' \
--exclude 'node_modules' \
--exclude 'lib' \
--exclude 'vendor/bundle' \
--exclude '_smugmug_cache' \
--exclude 'tmp' \
--exclude '.sass-cache' \
--exclude '_site' \
'/home/travis/newtheatre/history-project/' '/data/' &&\
cd /data"
installdep="echo '----- Install htmltest' &&\
curl https://htmltest.wjdp.uk > _bin/htmltest &&\
chmod +x _bin/htmltest &&\
echo '----- Bundle Install' &&\
bundle install --jobs=3 --retry=3 --deployment
echo '----- NPM Install' &&\
npm install
echo '----- Bower Install' &&\
bower install --allow-root"
build_site="echo '----- Building Site' &&\
gulp build"
test_site="echo '----- Testing Site' &&\
gulp test"
serve_site="echo '----- Serving Site' &&\
gulp dockerserver"
# Assemble the fragments, based on input parameters
do_script=false
while test $# -gt 0
do
case "$1" in
stop)
stopAtEnd=true
;;
start)
start
;;
install)
script="$script && $installdep"
do_script=true
;;
build)
script="$script && $build_site"
do_script=true
;;
test)
script="$script && $test_site"
do_script=true
;;
serve)
script="$script && $serve_site"
do_script=true
;;
*) echo "Unknown argument $1"
exit 1
;;
esac
shift
done
# If there weren't any input parameters, then do the default
if ${noParams:-false} ; then
doStart=false
docker exec history-project true 2>/dev/null || doStart=true
if ${doStart:-false} ; then
echo "----- Container not running, starting up"
start
else
echo "----- Container already running, continuing"
fi
script="$script && $installdep"
script="$script && $build_site"
script="$script && $test_site"
script="$script && $serve_site"
do_script=true
fi
# Run the script
if ${do_script:-false} ; then
docker exec -it history-project /bin/bash -lc "$script"
fi
if ${stopAtEnd:-false} ; then
stop
fi