forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·55 lines (45 loc) · 1.54 KB
/
release.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
#!/bin/bash
set -ex
OUTPUT=docker-worker-x64.tgz
while getopts "o:" opt; do
case "${opt}" in
o) OUTPUT=$OPTARG
;;
esac
done
DW_ROOT=$(mktemp -d)
trap "rm -rf $DW_ROOT" EXIT
# create an easy-to-use thing that will find the right paths, etc.
mkdir -p $DW_ROOT/bin
cat > $DW_ROOT/bin/docker-worker <<'EOF'
#!/bin/bash
DW_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )"
NODE=$DW_ROOT/node/bin/node
exec $NODE $DW_ROOT/src/main.js "${@}"
EOF
chmod +x $DW_ROOT/bin/docker-worker
# install docker-worker itself
for f in src schemas .npmignore package.json yarn.lock config.yml bin-utils; do
cp -r $PWD/$f $DW_ROOT
done
# Install Node
NODE_VERSION=$(echo "console.log(require('./package.json').engines.node)" | node)
mkdir $DW_ROOT/node
curl https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz | tar -C $DW_ROOT/node --strip-components=1 -xJf -
# Install Yarn (later to be removed)
curl -L https://yarnpkg.com/latest.tar.gz | tar --transform 's|yarn-[^/]*/|yarn/|' -C $DW_ROOT -zvxf -
# Install dependencies
PATH=$DW_ROOT/node/bin:$DW_ROOT/node_modules/.bin:$PATH
(
cd $DW_ROOT
# --ignore-engines is to ignore if we're using the wrong version of yarn
./yarn/bin/yarn install --dev --ignore-engines
)
# Clean up some stuff
rm -rf "$DW_ROOT/yarn"
rm -rf "$DW_ROOT/node/include"
rm -rf "$DW_ROOT/node/lib/node_modules/npm"
rm -rf "$DW_ROOT/node/bin/npm"
rm -rf "$DW_ROOT/node/bin/npx"
# tar up the result..
tar -C $DW_ROOT --transform 's|^\./|docker-worker/|' -czf $OUTPUT .