-
Notifications
You must be signed in to change notification settings - Fork 174
/
update-ciso-assistant.sh
executable file
·48 lines (37 loc) · 1.35 KB
/
update-ciso-assistant.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
#! /usr/bin/env bash
VERSION=${1:-community}
if [ "$VERSION" = "enterprise" ]; then
# Go to the enterprise directory
cd "enterprise/" || exit 1
fi
DB_FILE="db/ciso-assistant.sqlite3"
BACKUP_FILE="ciso-assistant-backup.sqlite3"
if [ "$VERSION" = "enterprise" ]; then
BACKEND_IMAGE="ghcr.io/intuitem/ciso-assistant-enterprise-backend:latest"
FRONTEND_IMAGE="ghcr.io/intuitem/ciso-assistant-enterprise-frontend:latest"
else
BACKEND_IMAGE="ghcr.io/intuitem/ciso-assistant-community/backend:latest"
FRONTEND_IMAGE="ghcr.io/intuitem/ciso-assistant-community/frontend:latest"
fi
echo "Update of the version : $VERSION"
# Backup the database
if [ ! -f "$DB_FILE" ]; then
echo "Error: No database found, please initialize CISO Assistant first"
exit 1
else
cp "$DB_FILE" "$BACKUP_FILE"
echo "Backup of the database created in $BACKUP_FILE"
fi
# Stop the containers
docker compose down
# Remove the images
docker rmi "$BACKEND_IMAGE" "$FRONTEND_IMAGE" 2> /dev/null
# Start the containers
docker compose up -d
# Wait for the database to be ready
echo "Giving some time for the database to be ready, please wait ..."
sleep 5
# Apply migrations
BACKEND_CONTAINER=$(docker ps --filter "ancestor=$BACKEND_IMAGE" --format "{{.Names}}")
docker compose exec "$BACKEND_CONTAINER" poetry run python manage.py migrate
echo "CISO assistant updated successfully"