-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker.sh
More file actions
73 lines (60 loc) · 2.11 KB
/
docker.sh
File metadata and controls
73 lines (60 loc) · 2.11 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
# Definisce una funzione che comunica se l'operazione precedente è andata a buon fine
f_check() {
if [ $? -eq 0 ]; then
res="\e[36m$2\e[0m"
else
res="\e[33m$3\e[0m"
fi
echo "$1: $res"
}
# Definisce una funzione che crea un container se non esiste già
f_start() {
name="$1"
image="$2"
shift 2
docker run --name $name --network vsync --restart unless-stopped -d $@ $image > /dev/null 2>&1
f_check "Container \"$name\"" "Started" "Skipped"
}
######################################################
# Ottengo il persorso della cartella corrente
dir="$(dirname "$(realpath $0)")"
# Specifico la configurazione del database di SzuruBooru
# Il database è esposto solo sulla rete virtuale creata da me, quindi non c'è problema se il mondo conosce la password
szuru_db_name=szuru
szuru_db_user=szuru
szuru_db_pass=szuru
# Crea i volumi esterni per Docker
mkdir -p ~/data/szuru_db ~/data/szuru_server ~/public
chmod -R 777 ~/data ~/public
# Crea una rete condivisa tra tutti i container
docker network create vsync > /dev/null 2>&1
f_check "Network" "Created" "Already exists"
# Rimuovi tutti i container spenti
docker container prune -f > /dev/null
# Esegui il container di Vsync
f_start vsync vsync
# Esegui il container del database di SzuruBooru
f_start szuru_db postgres:11-alpine \
-e "POSTGRES_DB=$szuru_db_name" \
-e "POSTGRES_USER=$szuru_db_user" \
-e "POSTGRES_PASSWORD=$szuru_db_pass" \
-v ~/data/szuru_db:/var/lib/postgresql/data
# Esegui il container del server di SzuruBooru
f_start szuru_server szurubooru/server \
-e "POSTGRES_HOST=szuru_db" \
-e "POSTGRES_DB=$szuru_db_name" \
-e "POSTGRES_USER=$szuru_db_user" \
-e "POSTGRES_PASSWORD=$szuru_db_pass" \
-v "$dir/szuru.yaml:/opt/app/config.yaml" \
-v ~/data/szuru_server:/data
# Esegui il container del client di SzuruBooru
f_start szuru_client szurubooru/client \
-e "BACKEND_HOST=szuru_server" \
-v ~/data/szuru_server:/data:ro
# Esegui il container di Nginx
f_start nginx nginx \
-p 80:80 \
-p 443:443 \
-v "$dir/nginx.conf:/etc/nginx/nginx.conf:ro" \
-v ~/public:/var/www/static:ro \
-v /etc/letsencrypt:/etc/letsencrypt:ro