-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_all_nodes.sh
executable file
·47 lines (35 loc) · 1.28 KB
/
build_all_nodes.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
#!/bin/bash
# example :
# to test the commands
# ./build_all_nodes.sh config_outs/config_5a2b0956-2201-4128-aba8-49c1fc43ddc3 your-name-here test
# to build all images
# ./build_all_nodes.sh config_outs/config_5a2b0956-2201-4128-aba8-49c1fc43ddc3 your-name-here build
# export images to image_outs folder
# ./build_all_nodes.sh config_outs/config_5a2b0956-2201-4128-aba8-49c1fc43ddc3 your-name-here save
config_path=$1
node_author=$2
run_mode=$3 # set "test" or "build"
image_name="$(echo $config_name'_'$node_name)"
network_name="$(ls $1/* | sed -n 2p)"
# removes back slash at the end of string if exist
path=${1%/}
for d in $path/* ; do
node_name="$(echo "$d" | cut -d/ -f 3)"
if [ $node_name != "shared_hosts" ]
then
config_name="$(echo $config_path |cut -d/ -f 2)"
image_name="$(echo $config_name'_'$node_name)"
if [ $run_mode == "test" ]
then
echo "sudo docker build -f Dockerfile_node -t $node_author/$image_name --build-arg node_path=$config_path/$node_name/$network_name ."
fi
if [ $run_mode == "build" ]
then
sudo docker build -f Dockerfile_node -t $node_author/$image_name --build-arg node_path=$config_path/$node_name/$network_name/ .
fi
if [ $run_mode == "save" ]
then
sudo docker save -o image_outs/$image_name.img $node_author/$image_name
fi
fi
done