forked from sourcegraph/zoekt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-deploy.sh
executable file
·55 lines (39 loc) · 1.17 KB
/
build-deploy.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
# this script packages up all the binaries, and a script (deploy.sh)
# to twiddle with the server and the binaries
set -ex
# Put the date first so we can sort.
if [[ -z "$VERSION" ]]; then
VERSION=$(date --iso-8601=minutes | tr -d ':' | sed 's|\+.*$||')
if [[ -d .git ]]; then
VERSION=${VERSION}-$(git show --pretty=format:%h -q)
fi
fi
set -u
out=zoekt-${VERSION}
mkdir -p ${out}
for d in $(find cmd/ -maxdepth 1 -type d)
do
go build \
-tags netgo \
-ldflags "-X github.com/sourcegraph/zoekt.Version=dev" \
-o ${out}/$(basename $d) \
github.com/sourcegraph/zoekt/$d
done
cat <<EOF > ${out}/deploy.sh
#!/bin/bash
echo "Set the following in the environment."
echo ""
echo ' export PATH="'$PWD'/bin:$PATH'
echo ""
set -eux
# Allow sandbox to create NS's
sudo sh -c 'echo 1 > /proc/sys/kernel/unprivileged_userns_clone'
# we mmap the entire index, but typically only want the file contents.
sudo sh -c 'echo 1 >/proc/sys/vm/overcommit_memory'
# allow bind to 80 and 443
sudo setcap 'cap_net_bind_service=+ep' bin/zoekt-webserver
EOF
chmod 755 ${out}/*
tar --owner=root --group=root -czf zoekt-deploy-${VERSION}.tar.gz ${out}/*
rm -rf ${out}