Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add community/enterprise update script #1085

Merged
merged 11 commits into from
Dec 1, 2024
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"
Loading