-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilder_script.sh
More file actions
executable file
·56 lines (46 loc) · 1.54 KB
/
builder_script.sh
File metadata and controls
executable file
·56 lines (46 loc) · 1.54 KB
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
#!/bin/bash
if ([ $# == 1 ] && [ $1 == '-h' -o $1 == '--help' ]); then
echo "USAGE:";
echo "builder_script.sh [INSTALL_PYTHON: (OFF)/ON] [OPENCV_VERSION: 4.0.1]";
echo -e "\nN.B.: This script was only tested with opencv 4.0.1"
exit 0;
fi
INSTALL_PYTHON="OFF"
OPENCV_VERSION="4.0.1"
if [ $# == 1 ]; then
INSTALL_PYTHON=$1;
fi
if [ $# == 2 ]; then
OPENCV_VERSION=$2;
fi
function check_bashrc() {
while read -r l; do
if [ "$l" = "# >>> docker-opencv script >>>" ]; then
echo "Function cvdocker already added to ~/.bashrc. Skipping."
return 1
fi
done < ~/.bashrc
return 0
}
function add_to_bashrc() {
echo "Adding function cvdocker to ~/.bashrc"
{
echo -e "# Line added by docker-opencv builder script"
echo -e "# >>> docker-opencv script >>>"
echo -e "function cvdocker() {"
echo -e "\tdocker container run \\"
echo -e "\t-v /home/\${USER}:/home/dckr \\"
echo -e "\t-v /tmp/.X11-unix:/tmp/.X11-unix \\"
echo -e "\t--workdir /home/dckr \\"
echo -e "\t-e DISPLAY=\${DISPLAY} \\"
echo -e "\t-p 5000:5000 -p 8888:8888 -p 2000:2000\\"
echo -e "\t-it docker_opencv_image /bin/bash"
echo -e "}"
echo -e "# <<< docker-opencv script <<<\n"
} >> ~/.bashrc
echo "Done! You can now run the container simply by typing 'cvdocker'. If it doesn't work reload the .bashrc with 'source ~/.bashrc'"
}
echo "Starting docker build"
docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) --build-arg PYTHON=${INSTALL_PYTHON} --build-arg OPENCV_VERSION=${OPENCV_VERSION} --tag=docker_opencv_image . \
&& check_bashrc \
&& add_to_bashrc