Blame view
deploy.sh
2.51 KB
a7065b1b3 Add deploy and de... |
1 |
#!/bin/sh |
bb68d7fdb Dump all containe... |
2 |
dump_logs() { |
33ea208d5 Fix typo |
3 |
CONTAINERS="suricata elasticsearch logstash kibana webserver composer api od mltd mqtt timescaledb grafana" |
bb68d7fdb Dump all containe... |
4 |
for CONTAINER in $CONTAINERS; do |
83d192a8b Mark end of logs too |
5 |
echo "*** Logs for kea_$CONTAINER (start) ***" |
bb68d7fdb Dump all containe... |
6 |
docker logs kea_$CONTAINER |
83d192a8b Mark end of logs too |
7 |
echo "*** Logs for kea_$CONTAINER (end) ***" |
bb68d7fdb Dump all containe... |
8 |
done |
626f6d63f Show contents of ... |
9 10 11 |
echo "*** Contents of data directory (start) ***" ls -lR data echo "*** Contents of data directory (end) ***" |
bb68d7fdb Dump all containe... |
12 |
} |
a5d31f18b Show current dire... |
13 |
echo "Current directory: `pwd`" |
a7065b1b3 Add deploy and de... |
14 15 16 17 |
# Login into the CUREX registry docker login https://registry.curex-project.eu:443/artifactory/curex-local/ # pull all containers |
fc3cc7824 Move composer to ... |
18 19 20 21 |
docker-compose \ -f docker-compose-jfrog.yml \ -f docker-compose-jfrog-composer.yml \ pull |
a7065b1b3 Add deploy and de... |
22 23 24 25 |
sleep 1 # Prepare installation |
a6777d113 Add some messages |
26 |
echo "Preparing installation..." |
a7065b1b3 Add deploy and de... |
27 |
cd api |
41c17fd87 Fix filename |
28 |
cp .env.example .env |
a7065b1b3 Add deploy and de... |
29 30 31 32 |
docker run --rm -v $(pwd):/app \ registry.curex-project.eu:443/curex-local/kea_composer:2.0.7 \ install cd .. |
3f6bad8ff Run create_volume... |
33 |
sh ./create_volumes.sh |
a7065b1b3 Add deploy and de... |
34 |
|
1898c47f2 Loop until all al... |
35 36 |
# Keep the timestamp of when starting up containers TIME_START=`date +%s` |
00ba62308 Stop containers b... |
37 |
# Just in case something is up from previous runs |
a6777d113 Add some messages |
38 |
echo "Bringing down any previous containers..." |
00ba62308 Stop containers b... |
39 |
docker-compose -f docker-compose-jfrog.yml down |
a7065b1b3 Add deploy and de... |
40 |
# Run containers |
a6777d113 Add some messages |
41 |
echo "Bringing up containers..." |
a7065b1b3 Add deploy and de... |
42 |
docker-compose -f docker-compose-jfrog.yml up --detach |
1898c47f2 Loop until all al... |
43 44 |
# loop until all containers are up |
a6777d113 Add some messages |
45 |
echo "Checking if all containers are up..." |
942cf4e44 Fix loop |
46 |
while true; do |
1898c47f2 Loop until all al... |
47 48 49 50 51 52 53 54 |
# if any container other than composer has exited, bail out res=`docker ps -a | \ grep "/curex-local/kea_" | \ grep -v "kea_composer" | \ grep "Exited" | \ wc -l` if [ $res -gt 0 ]; then echo "ERROR: Some containers have exited." |
24c412072 Show header line |
55 |
docker ps -a | grep "^CONTAINER\|/curex-local/kea_" |
bb68d7fdb Dump all containe... |
56 |
dump_logs |
b9f8960be Stop containers a... |
57 |
docker-compose -f docker-compose-jfrog.yml down |
1898c47f2 Loop until all al... |
58 59 60 61 62 63 64 65 66 |
exit 1 fi # count containers that are up res=`docker ps -a | \ grep "/curex-local/kea_" | \ grep -v "kea_composer" | \ grep "Up" | \ wc -l` if [ $res -eq 11 ]; then |
a6777d113 Add some messages |
67 |
echo "All good!" |
1898c47f2 Loop until all al... |
68 69 70 71 72 73 74 |
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 Dump all containe... |
75 |
dump_logs |
b9f8960be Stop containers a... |
76 |
docker-compose -f docker-compose-jfrog.yml down |
1898c47f2 Loop until all al... |
77 78 79 80 81 82 83 |
exit 2 fi sleep 1 done # Wait a bit more sleep 10 |
a7065b1b3 Add deploy and de... |
84 85 |
# create and populate the database |
a6777d113 Add some messages |
86 |
echo "Creating and populating the database..." |
9eacacfe5 Disable the TTY i... |
87 |
docker-compose -f docker-compose-jfrog.yml exec -T api php artisan migrate:fresh --seed --force |
004404c2c Try to debug Jenk... |
88 89 |
docker-compose -f docker-compose-jfrog.yml exec -T api pwd docker-compose -f docker-compose-jfrog.yml exec -T api ls -l |
a7065b1b3 Add deploy and de... |
90 |