-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add community/enterprise update script (#1085)
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |