-
Notifications
You must be signed in to change notification settings - Fork 35
/
docker_install.sh
117 lines (96 loc) · 2.9 KB
/
docker_install.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/bash
ISKYLIMS_VERSION="3.0.0"
usage() {
cat << EOF
This script install and upgrade the iskylims app.
usage : $0 --demo_data
Optional input data:
--demo_data | provide already dowloaded demo data from zenodo
Examples:
Install demo docker system
bash $0
Provide already downloaded data from zenodo (compressed)
bash $0 --demo_data /path/to/iskylims_demo_data.tar.gz
EOF
}
# translate long options to short
reset=true
for arg in "$@"
do
if [ -n "$reset" ]; then
unset reset
set -- # this resets the "$@" array so we can rebuild it
fi
case "$arg" in
# OPTIONAL
--demo_data) set -- "$@" -d ;;
# ADITIONAL
--help) set -- "$@" -h ;;
--version) set -- "$@" -v ;;
# PASSING VALUE IN PARAMETER
*) set -- "$@" "$arg" ;;
esac
done
# SETTING DEFAULT VALUES
demo_data=false
# PARSE VARIABLE ARGUMENTS WITH getops
options=":d:vh"
while getopts $options opt; do
case $opt in
d)
demo_data=$OPTARG
;;
h )
usage
exit 1
;;
v )
echo $ISKYLIMS_VERSION
exit 1
;;
\?)
echo "Invalid Option: -$OPTARG" 1>&2
usage
exit 1
;;
: )
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
* )
echo "Unimplemented option: -$OPTARG" >&2;
exit 1
;;
esac
done
shift $((OPTIND-1))
echo "Deploying test containers..."
docker compose build --no-cache
docker compose up -d
echo "Waiting 20 seconds for starting database and web services..."
sleep 20
echo "Creating the database structure for iSkyLIMS"
docker exec -it iskylims_app python3 manage.py migrate
docker exec -it iskylims_app python3 manage.py makemigrations django_utils core wetlab drylab
docker exec -it iskylims_app python3 manage.py migrate
echo "Creating super user "
docker exec -it iskylims_app python3 manage.py createsuperuser
echo "Loading in database initial data"
docker exec -it iskylims_app python3 manage.py loaddata conf/first_install_tables.json
docker exec -it iskylims_app python3 manage.py loaddata test/test_data.json
echo "Download testing files and copy it to samba container"
if [ "$demo_data" == "false" ];then
wget https://zenodo.org/record/8091169/files/iskylims_demo_data.tar.gz
demo_data="./iskylims_demo_data.tar.gz"
fi
docker cp $demo_data samba:/mnt
docker exec -it samba tar -xf /mnt/iskylims_demo_data.tar.gz -C /mnt
echo "deleting compress testing file"
docker exec -it samba rm /mnt/iskylims_demo_data.tar.gz
if [ "$demo_data" == "false" ];then
rm -f $demo_data
fi
echo "Running crontab"
docker exec -it iskylims_app python3 manage.py crontab add
docker exec -it iskylims_app service cron start
echo "You can now access iskylims via: http://localhost:8001"