-
Notifications
You must be signed in to change notification settings - Fork 14
/
run.sh
executable file
·93 lines (85 loc) · 3.76 KB
/
run.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
#!/bin/bash
MODE="$1"
case "$1" in
help)
echo "------ General development ------"
echo "Assuming you have docker installed ./run.sh develop"
echo "will download the required docker containers and start"
echo "a server at http://localhost:8000"
echo
echo "----- Update docker dependencies -----"
echo "run ./run.sh pull-deps to get the latest version of the build dockers"
exit 0
;;
develop|pull-deps|ghci|deploy)
;;
*)
echo $"Usage: $0 {develop|pull-deps|ghci|help}"
exit 1
esac
case "$MODE" in
develop)
# Start the javascript watcher
SCRIPTS_WATCH=$(docker run -dt -u `id -u`:`id -g` \
-v $PWD/content/scripts:/work/scripts \
-v $PWD/content/assets:/work/assets \
dragonflyscience/website-scripts bash -c "ls scripts/*.js | \
entr -r bash -c 'compile-modules convert scripts/dragonfly.js > assets/dragonfly.js'")
# start the stylesheet watcher
STYLESHEETS_WATCH=$(docker run -dt -u `id -u`:`id -g` \
-v $PWD/content/stylesheets:/work/stylesheets \
-v $PWD/content/assets:/work/assets \
dragonflyscience/website-sass \
bash -c "find stylesheets -name *.scss | \
entr -r scss stylesheets/dragonfly.scss assets/dragonfly.css")
docker inspect dragonfly-website >/dev/null 2>&1
if [ $? != 0 ]; then
docker run -v /dist -v /var/cache/dragonflyweb -v /tmp/build \
--name dragonfly-website dragonflyscience/website-hakyll bash
fi
# build the dragonweb haskell binary
docker run --rm -w /work -v $PWD/haskell:/work \
--volumes-from dragonfly-website \
dragonflyscience/website-hakyll ghc -o /dist/dragonfly-hakyll \
-odir /tmp/build -hidir /tmp/build Site.hs
# Finally start the actual develop container
docker run --rm -it -p 8000:8000 -w /work -v $PWD/content:/work \
--volumes-from dragonfly-website \
dragonflyscience/website-hakyll \
/dist/dragonfly-hakyll watch
docker rm -f $STYLESHEETS_WATCH
docker rm -f $SCRIPTS_WATCH
;;
pull-deps)
docker pull dragonflyscience/website-hakyll
docker pull dragonflyscience/website-sass
docker pull dragonflyscience/website-scripts
;;
ghci)
docker run --rm -it -w /work -v $PWD/haskell:/work \
dragonflyscience/website-hakyll ghci Site.hs
;;
deploy)
./run.sh pull-deps &&
rm -f content/assets/* &&
docker run --rm -u $(id -u):$(id -g) \
-v $PWD/content/stylesheets:/work/stylesheets \
-v $PWD/content/assets:/work/assets \
dragonflyscience/website-sass scss --style compressed --sourcemap=none \
stylesheets/dragonfly.scss assets/dragonfly.css &&
docker run --rm -u $(id -u):$(id -g) \
-v $PWD/content/scripts:/work/scripts \
-v $PWD/content/assets:/work/assets \
dragonflyscience/website-scripts bash -c \
"compile-modules convert scripts/dragonfly.js | yuglify --terminal > assets/dragonfly.js" &&
name=$(uuidgen -r) &&
docker run --name $name -w /work -v $PWD:/work \
dragonflyscience/website-hakyll \
bash -c "cd haskell && ghc -o /tmp/dragonfly-hakyll -odir /tmp -hidir /tmp/ Site.hs && \
cd /work/content && /tmp/dragonfly-hakyll build" &&
docker cp $name:/var/cache/dragonflyweb/main/site /tmp/$name/ &&
docker rm $name &&
rsync -av --delete /tmp/$name/site/ \
[email protected]:/var/www/static/www.dragonfly.co.nz
;;
esac