-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_all.sh
91 lines (71 loc) · 2.46 KB
/
run_all.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
#!/bin/bash
# Windows wsl
# sudo chown ${USER}:docker /home/dieter/keycloak/data
#Permission denied in shinyproxy:
#https://stackoverflow.com/questions/64099538/shinyproxy-error-500-failed-to-start-container-caused-by-java-io-ioexceptio
# sudo usermod -aG docker $USER
# Must be run after each server reboot
#sudo chown $USER:docker /var/run/docker.sock
# shellcheck shell=bash
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -euxo pipefail
# shellcheck disable=SC1091
source ./chown_docker_sock.sh
dos2unix ./.Renviron
# Make sure that ./.Renviron is valid
set -a
# shellcheck disable=SC1090
# shellcheck disable=SC2002
source <(cat ./.Renviron | sed -e '/^#/d;/^\s*$/d' -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g")
set +a
if [[ $R_CONFIG_ACTIVE != *"keycloak"* ]];
then
echo "R_CONFIG_ACTIVE is set to ${R_CONFIG_ACTIVE} in .Renviron"
echo "You must use keycloak_devel or keycloak_production"
exit 1
fi
echo "$R_CONFIG_ACTIVE"
if [[ $R_CONFIG_ACTIVE = "keycloak_production" ]]; then
ln -sf ./inst/Renviron_production ./.env
echo "Read <<./inst/Renviron_production>>"
else
ln -sf ./inst/Renviron_devel ./.env
fi
set -a
# shellcheck disable=SC1090
# shellcheck disable=SC2002
source <(cat ./.env | sed -e '/^#/d;/^\s*$/d' -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g")
set +a
if [ -z "$ANOMANOR_SECRET" ]; then
echo "ANOMANOR_SECRET is empty"
exit 1
fi
docker compose down
docker system prune -f
#docker network rm anomanor-net
docker rmi -f anomanor
docker build --tag anomanor -f Dockerfile_anomanor \
--build-arg R_CONFIG_ACTIVE \
--build-arg ANOMANOR_DATA \
--build-arg ANOMANOR_ADMIN_USERNAME\
--build-arg ANOMANOR_ADMIN_PASSWORD \
.
# Thanks, chatgpt. (not tested)
# Get the last modification time of application.yml
app_mod_time=$(stat -c %Y application.yml)
if docker inspect anomanor_shiny-shinyproxy >/dev/null 2>&1
then
# Get the creation time of the Docker image
image_build_time=$(docker inspect --format='{{.Created}}' anomanor_shiny-shinyproxy | xargs date +%s -d)
# Compare the times and remove the image if application.yml is newer
if [ "$app_mod_time" -gt "$image_build_time" ]
then
docker rmi -f anomanor_shiny-shinyproxy
fi
fi
docker compose up --build -d
#docker compose up --build -d traefik shinyproxy keycloak
#docker network inspect -f '{{json .Containers}}' anomanor-net | jq '.[] | .Name + ":" + .IPv4Address'
#docker logs keycloak --follow
#docker logs shinyproxy --follow
#docker logs traefik --follow