forked from taskcluster/docker-worker
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild
executable file
·81 lines (68 loc) · 1.59 KB
/
build
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
#! /bin/bash
set -e
cmd_help() {
echo "Usage: ./deploy/bin/build"
echo
echo 'Wrapper for the `packer` build tool with docker-worker specific logic.'
echo
echo "Commands:"
echo " help: show this help message"
echo " app: build the app packer target"
echo " base: build the base packer target"
}
packer_run() {
echo $@
echo
echo
echo "packer $@"
time packer $@
}
template_vars() {
echo "deploy/target/packer/$1.json"
}
packer_config() {
echo "deploy/packer/$1.json"
}
cmd_app() {
# Package up the node app.
tar --exclude='./node_modules' --exclude='./*.pub' --exclude='./build/' --exclude='./deploy' --exclude='.test' --exclude='.git' --exclude='.vagrant' --exclude='./.DS_Store' --exclude='./vagrant/' --exclude='app.box' -zcvf docker-worker.tgz .
local git_rev=$(git rev-parse --verify HEAD)
# Configure the deployment if needed...
make -j100 -C deploy
packer_run \
build \
$@ \
-var-file $(template_vars app) \
-var "templateContents=deploy/deploy.tar.gz" \
-var "npmPackage=docker-worker.tgz" \
-var "workerRevision=$git_rev" \
$(packer_config app)
}
cmd_base() {
local git_rev=$(git rev-parse --verify HEAD)
# build config file
make target/packer/base.json -C deploy
packer_run \
build \
$@ \
-var-file $(template_vars base) \
-var "workerRevision=$git_rev" \
$(packer_config base)
}
if [ ! -x $(which packer) ];
then
echo "This tool requires packer go download and install it first."
cmd_help
exit 1
fi
case "$1" in
"app")
cmd_app ${@:2}
;;
"base")
cmd_base ${@:2}
;;
*)
cmd_help
;;
esac