-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·56 lines (48 loc) · 1.47 KB
/
run.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
#! /usr/bin/env bash
while getopts 'hif' opt; do
case "$opt" in
h)
echo "Kjører opp utvikler miljøet. Bruk: $(basename $0) [-h] [-i] [-f]"
echo " -h denne hjelpeteksten"
echo " -i sletter volumes, kjører opp postgres, og laster inn datadump fra git"
echo " -f fjerner gammelt backend og frackend image"
exit 0
;;
i)
echo "Sletter volumes ..."
docker-compose down -v
echo "Initialiserer database..."
docker-compose up postgres -d
sleep 3
DB_DUMP=/tmp/db_script.sql
curl -o $DB_DUMP https://raw.githubusercontent.com/navikt/lydia-api/main/scripts/db/lydia-api-container-db_localhost-2024_11_29_08_52_44-dump.sql
PGPASSWORD=test psql -h localhost -p 5432 -U postgres -f $DB_DUMP > /dev/null
rm $DB_DUMP
sleep 1
docker-compose stop postgres
;;
f)
docker-compose down
docker-compose pull authserver azure postgres redis kafka wonderwall
echo "Sletter gammelt backend og frackend image"
docker rmi $(docker images | grep -E "lydia-api|lydia-radgiver-frontend" | cut -w -f3)
;;
?)
echo -e "Ugyldig argument. Bruk: $(basename $0) [-h] [-i] [-f]"
exit 1
;;
esac
done
shift "$(($OPTIND -1))"
# stop evt kjørende tjenester
docker-compose stop
# kjør opp tjenester (dette migrerer databasen til nyeste versjon)
docker-compose up -d
if [ $? -eq 0 ]
then
sleep 5
# kjør opp frontend
cd client
npm install
npm run dev
fi