Blame view
deploy.sh
1.91 KB
a7065b1b3
|
1 |
#!/bin/sh |
bb68d7fdb
|
2 |
dump_logs() { |
248aceaba
|
3 |
CONTAINERS="suricata elasticsearch logstash kibana webserver api od mltd mqtt timescaledb grafana" |
bb68d7fdb
|
4 |
for CONTAINER in $CONTAINERS; do |
83d192a8b
|
5 |
echo "*** Logs for kea_$CONTAINER (start) ***" |
bb68d7fdb
|
6 |
docker logs kea_$CONTAINER |
83d192a8b
|
7 |
echo "*** Logs for kea_$CONTAINER (end) ***" |
bb68d7fdb
|
8 9 |
done } |
a7065b1b3
|
10 11 12 13 |
# Login into the CUREX registry docker login https://registry.curex-project.eu:443/artifactory/curex-local/ # pull all containers |
fc3cc7824
|
14 15 |
docker-compose \ -f docker-compose-jfrog.yml \ |
fc3cc7824
|
16 |
pull |
a7065b1b3
|
17 18 |
sleep 1 |
1898c47f2
|
19 20 |
# Keep the timestamp of when starting up containers TIME_START=`date +%s` |
00ba62308
|
21 |
# Just in case something is up from previous runs |
bf34743c6
|
22 23 |
echo "Bringing down any previous containers that are still running..." ./delete.sh |
00ba62308
|
24 |
|
a7065b1b3
|
25 |
# Run containers |
a6777d113
|
26 |
echo "Bringing up containers..." |
a7065b1b3
|
27 |
docker-compose -f docker-compose-jfrog.yml up --detach |
1898c47f2
|
28 29 |
# loop until all containers are up |
a6777d113
|
30 |
echo "Checking if all containers are up..." |
942cf4e44
|
31 |
while true; do |
1898c47f2
|
32 33 34 |
# if any container other than composer has exited, bail out res=`docker ps -a | \ grep "/curex-local/kea_" | \ |
1898c47f2
|
35 36 37 38 |
grep "Exited" | \ wc -l` if [ $res -gt 0 ]; then echo "ERROR: Some containers have exited." |
24c412072
|
39 |
docker ps -a | grep "^CONTAINER\|/curex-local/kea_" |
bb68d7fdb
|
40 |
dump_logs |
b9f8960be
|
41 |
docker-compose -f docker-compose-jfrog.yml down |
1898c47f2
|
42 43 44 45 46 |
exit 1 fi # count containers that are up res=`docker ps -a | \ grep "/curex-local/kea_" | \ |
1898c47f2
|
47 48 49 |
grep "Up" | \ wc -l` if [ $res -eq 11 ]; then |
a6777d113
|
50 |
echo "All good!" |
1898c47f2
|
51 52 53 54 55 56 57 |
break fi # only wait for 10 mins until everything is up. It should be more than # enough. TIME_NOW=`date +%s` if [ $((TIME_NOW - TIME_START)) -ge 600 ]; then echo "ERROR: Timeout exceeded." |
bb68d7fdb
|
58 |
dump_logs |
b9f8960be
|
59 |
docker-compose -f docker-compose-jfrog.yml down |
1898c47f2
|
60 61 62 63 64 65 |
exit 2 fi sleep 1 done # Wait a bit more |
ef0f0c47c
|
66 |
sleep 60 |
a7065b1b3
|
67 68 |
# create and populate the database |
a6777d113
|
69 |
echo "Creating and populating the database..." |
9eacacfe5
|
70 |
docker-compose -f docker-compose-jfrog.yml exec -T api php artisan migrate:fresh --seed --force |
a7065b1b3
|
71 |