Skip to content

Commit

Permalink
Add community/enterprise update script (#1085)
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-intuitem authored Dec 1, 2024
2 parents 0961b1e + 3648de3 commit a201a4a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions enterprise/update-ciso-assistant-enterprise.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /usr/bin/env bash
pushd ..
./update-ciso-assistant.sh enterprise
popd
48 changes: 48 additions & 0 deletions update-ciso-assistant.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,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"

0 comments on commit a201a4a

Please sign in to comment.