-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdgraph-builder.sh
55 lines (45 loc) · 1.7 KB
/
dgraph-builder.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
export GOOS=$1
export COMMIT=$2
if [ $GOOS == "linux" ]
then
echo "Building for 'linux'"
#export BINARY_PATH="/root/go/bin/dgraph"
elif [ $GOOS == "darwin" ]
then
echo "Building for 'darwin'"
#export BINARY_PATH="/root/go/bin/darwin_amd64/dgraph"
elif [ $GOOS == "windows" ]
then
echo "Building for 'windows'"
#export BINARY_PATH="/root/go/bin/windows_amd64/dgraph"
else
echo "no GOOS is entered, exiting"
exit 1
fi
if [ -z "$COMMIT" ]
then
echo "no COMMIT is entered, choosing master"
export COMMIT="master"
else
echo "Building for commit $COMMIT"
fi
# cleanup dgraph binary
rm -rf /tmp/dgraph-builder
mkdir /tmp/dgraph-builder
# build container base
docker build -t dgraph-builder /Users/sudhishkr/scratch/github/skrdgraph/dgraph-builder
# run the container
docker run --name="dgraph-builder" --env GOOS=$GOOS -v /tmp/dgraph-builder:/dgraph-builder dgraph-builder &>/dev/null &
sleep 3
# exec cmd into the container
docker exec -it $(docker ps -q --filter 'name=dgraph-builder') /bin/bash -c "git clone https://github.com/dgraph-io/dgraph.git"
docker exec -it $(docker ps -q --filter 'name=dgraph-builder') /bin/bash -c "CGO_ENABLED=0"
docker exec -it $(docker ps -q --filter 'name=dgraph-builder') /bin/bash -c "cd dgraph; git checkout $COMMIT; CGO_ENABLED=0 make dgraph;"
docker exec -it $(docker ps -q --filter 'name=dgraph-builder') /bin/bash -c "cp /src/dgraph/dgraph/dgraph /dgraph-builder/dgraph"
# clean up
docker stop $(docker ps -aq --filter 'name=dgraph-builder')
docker rm $(docker ps -aq --filter 'name=dgraph-builder')
# binary
echo "Binary created at /tmp/dgraph-builder/dgraph"
ls -alrt /tmp/dgraph-builder/dgraph