-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathrun-docker-compose.sh
More file actions
executable file
·86 lines (67 loc) · 2.45 KB
/
Copy pathrun-docker-compose.sh
File metadata and controls
executable file
·86 lines (67 loc) · 2.45 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
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
#!/bin/bash
VOLUME_ALREADY_EXISTS=10
VOLUME_CREATION_FAIL=20
function create-volume {
if [ ! "$(docker volume ls -q -f name=$1)" ]; then
echo -e "\nCreazione del docker volume $1"
docker volume create --name=$1
res=$?
if [[ $res != 0 ]]; then
return $VOLUME_CREATION_FAIL; fi
else
echo -e "\nIgnorata creazione del docker volume $1: volume gia' esistente"
return $VOLUME_ALREADY_EXISTS
fi
return 0
}
function create-volume-with-data {
create-volume $1
res=$?
if [[ $res != 0 ]]; then
# skip data initialization if the volume creation fails or if it already exists
return $res; fi
echo -e "\nInizializzazione del docker volume $1 con dati provenienti da $2"
volume_mountpoint=$(docker volume inspect $1 | jq .[0].Mountpoint | sed 's/"//g')
sudo cp -R $2* $volume_mountpoint
res=$?
if [[ $res != 0 ]]; then
echo -e "\nFallback: inizializzazione del docker volume per creazione container temporaneo: questa operazione potrebbe richiedere un po' di tempo..."
tmp_container_name="tmp-$RANDOM$RANDOM$RANDOM"
docker run -d --rm --name $tmp_container_name -v $1:/root alpine tail -f /dev/null
res=$?
if [[ $res != 0 ]]; then
return $VOLUME_CREATION_FAIL; fi
docker cp $2/. $tmp_container_name:/root/
res=$?
docker stop $tmp_container_name
if [[ $res != 0 ]]; then
return $VOLUME_CREATION_FAIL; fi
fi
echo -e "\nInizializzazione del docker volume $1 terminata"
return 0
}
create-volume-with-data satosa-saml2spid_nginx_certs nginx/certs/
res=$?
if [[ $res == $VOLUME_CREATION_FAIL ]]; then
echo -e "\nERRORE: setup docker volumes fallita\n"
return 1
fi
create-volume satosa-saml2spid_mongodata
res=$?
if [[ $res == $VOLUME_CREATION_FAIL ]]; then
echo -e "\nERRORE: setup docker volumes fallita\n"
return 1
fi
echo -e "\n"
echo -e "Provo a scaricare le nuove versioni. \n"
docker compose -f docker-compose.yml pull
echo -e "\n"
echo -e "Provo a fare il down della composizione. \n"
docker compose -f docker-compose.yml down -v
echo -e "\n"
echo -e "Tiro su la composizione, in caso, con le nuove versioni delle immagini. \n"
docker compose -f docker-compose.yml build django_sp
docker compose -f docker-compose.yml up -d --wait --wait-timeout 60
echo -e "\n"
echo -e "Completato. Per visionare i logs: 'docker-compose -f docker-compose.yml logs -f'"
exit 0