-
Notifications
You must be signed in to change notification settings - Fork 702
Expand file tree
/
Copy pathdocker-compose.sh
More file actions
executable file
·53 lines (42 loc) · 1.62 KB
/
docker-compose.sh
File metadata and controls
executable file
·53 lines (42 loc) · 1.62 KB
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
#! /bin/bash
set -euo pipefail
DOCKER_COMPOSE_FILE=docker-compose.yml
EXPECTED_OWNER="1001:1001"
is_linux_gnu_stat() {
stat -c '%u:%g' . >/dev/null 2>&1
}
get_owner_linux() {
stat -c '%u:%g' "$1"
}
if [ -d ./db ]; then
echo "The database seems already created. You should launch 'docker compose up -d' instead."
echo "For a clean start, you can remove the db folder, and then run 'docker compose rm -fs' and start over"
exit 1
fi
mkdir -p ./db
if is_linux_gnu_stat; then
DB_OWNER="$(get_owner_linux ./db)"
if [ "$DB_OWNER" != "$EXPECTED_OWNER" ]; then
echo "Fixing ownership of ./db (was $DB_OWNER, expected $EXPECTED_OWNER)"
if ! chown -R "$EXPECTED_OWNER" ./db 2>/dev/null; then
echo "chown failed, retrying with sudo..."
sudo chown -R "$EXPECTED_OWNER" ./db
fi
fi
else
echo "Non-Linux (no GNU stat detected): skipping ownership fix for ./db"
fi
echo "Starting CISO Assistant services..."
docker compose -f "${DOCKER_COMPOSE_FILE}" pull
echo "Initializing the database. This can take up to 2 minutes, please wait.."
docker compose -f "${DOCKER_COMPOSE_FILE}" up -d
echo "Waiting for CISO Assistant backend to be ready..."
until docker compose -f "${DOCKER_COMPOSE_FILE}" exec -T backend curl -f http://localhost:8000/api/health/ >/dev/null 2>&1; do
echo "Backend is not ready - waiting 10s..."
sleep 10
done
echo "Backend is ready!"
echo "Creating superuser..."
docker compose -f "${DOCKER_COMPOSE_FILE}" exec backend poetry run python manage.py createsuperuser
echo "Initialization complete!"
echo "You can now access CISO Assistant at https://localhost:8443 (or the host:port you've specified)"