forked from casper-network/casper-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_make.sh
executable file
·69 lines (60 loc) · 2.03 KB
/
docker_make.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
# Images used in this script are build in CasperLabs/buildenv repo
# This allows make commands without local build environment setup or
# using an OS version other than locally installed.
set -e
package="docker_make.sh"
valid_docker_images=("node-build-u1804" "node-build-u2004")
default_image=${valid_docker_images[0]}
function help {
echo "$package - issue make commands in docker environment"
echo " "
echo "$package [options] command"
echo " "
echo "options:"
echo "-h, --help show brief help"
echo "--image=DOCKER_IMAGE specify docker image to use: ${valid_docker_images[*]}"
echo " Image will default to ${default_image} if not given"
echo
echo "Ex: '$package all' will execute 'make all' on ${default_image}."
echo
echo "Note: The results will be in your ./target or ./target-as directory and"
echo " might not be compatible with your local system"
exit 0
}
while test $# -gt 0; do
case "$1" in
-h|--help)
help
;;
--image*)
image=`echo $1 | sed -e 's/^[^=]*=//g'`
if [[ " ${valid_docker_images[*]} " == *" $image "* ]]; then
docker_image=$image
else
echo "Invalid docker image passed in: $image"
echo "Possible images are: ${valid_docker_images[*]}."
fi
shift
;;
*)
break
;;
esac
done
if [ -z "$1" ]; then
echo "make command not given."
# echo "Using 'list' to show targets."
# make_command="list"
exit 1
else
make_command="$1"
fi
if [ -z "$docker_image" ]; then
echo "Defaulting build image to ${default_image}."
docker_image=${default_image}
fi
docker pull casperlabs/${docker_image}:latest
# Getting user and group to chown/chgrp target folder from root at end.
# Cannot use the --user trick as cached .cargo in image is owned by root.
command="cd /casper-node; make ${make_command}; chown -R -f $(id -u):$(id -g) ./target ./target_as ./execution_engine_testing/casper_casper;"
docker run --rm --volume $(pwd):/casper-node casperlabs/${docker_image}:latest /bin/bash -c "${command}"