-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·87 lines (73 loc) · 2.36 KB
/
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
#!/usr/bin/env bash
set -eE
set -u
INSTALLED_VERSION=""
ENV_USER=".env.user"
BASEDIR=$(dirname "$0")
source "$BASEDIR"/install/cli.sh
source "$BASEDIR"/install/check-min-req.sh
# Load the .env data
source "$BASEDIR"/.env
dc="docker compose --env-file .env --env-file $ENV_USER"
catch_dc_errors() {
echo ""
echo "================================================================="
echo ""
echo " An error during InfiniMetrics installation has occurred. "
echo " Please see an output of \`$dc logs\` "
echo " command."
echo ""
echo "================================================================="
echo ""
}
# Pull images from dotenv file
echo "INFO: images in dotenv file"
echo "CLICKHOUSE_IMAGE: $CLICKHOUSE_IMAGE"
echo "POSTGRES_IMAGE: $POSTGRES_IMAGE"
echo "NGINX_IMAGE: $NGINX_IMAGE"
echo "INFINIMETRICS_IMAGE: $INFINIMETRICS_IMAGE"
echo ""
declare -a images=("$CLICKHOUSE_IMAGE" "$POSTGRES_IMAGE" "$NGINX_IMAGE" "$INFINIMETRICS_IMAGE")
for img in "${images[@]}"
do
if [ -z "$(docker images -q $img 2> /dev/null)" ]; then
echo "INFO: Image $img is missing, pulling..."
docker image pull $img
else
echo "INFO: Image $img existing, skipping pulling."
fi
done
echo "INFO: Initializing data directories ..."
source "$BASEDIR"/install/init-data.sh
# turn everything off
echo "INFO: Stopping containers ..."
$dc down --remove-orphans --rmi local --timeout 120
trap 'catch_dc_errors' ERR
# build local docker images
echo "INFO: Building images ..."
$dc build postgres
echo "INFO: Docker images built"
if [ ! "$SKIP_INIT" == "1" ]; then
echo "INFO: Starting web container to run database migrations..."
set -x
$dc run --rm web infinimetrics setup
INSTALLED_VERSION=$($dc run --rm web infinimetrics --version)
set +x
fi
if [ "$START_CONTAINERS" == "1" ]; then
# start all the other services
echo "INFO: Starting all services inside the compose..."
$dc up -d --wait
else
echo ""
echo "================================================================="
echo ""
echo " SUCCESS: InfiniMetrics installation has been completed."
echo " InfiniMetrics installed version is $INSTALLED_VERSION"
echo " Run the following command to get InfiniMetrics running:"
echo ""
echo " $dc up -d"
echo ""
echo "=================================================================="
echo ""
fi