Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6cb41c1277 | |||
| f0d02d6af1 | |||
| 6f5e24104b |
@@ -20,11 +20,13 @@ show_help() {
|
||||
echo " restart-tenant <id> 'Restart' a single tenant (clears cache/sessions)"
|
||||
echo " restart-all Restart all application containers (zero-downtime reload)"
|
||||
echo " list List active tenants"
|
||||
echo " -h, --help Show this help message"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " ./manage-tenant.sh add school_a 10001"
|
||||
echo " ./manage-tenant.sh remove test_tenant"
|
||||
echo " ./manage-tenant.sh restart-all"
|
||||
echo " ./manage-tenant.sh -h"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -73,6 +75,9 @@ COMMAND=$1
|
||||
TENANT_ID=$2
|
||||
|
||||
case "$COMMAND" in
|
||||
-h|--help)
|
||||
show_help
|
||||
;;
|
||||
add)
|
||||
if [ -z "$TENANT_ID" ]; then
|
||||
echo "Error: Please provide a tenant_id."
|
||||
|
||||
+22
-3
@@ -5,6 +5,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
COMPOSE_FILE="docker-compose-multitenant.yml"
|
||||
ENV_FILE="$SCRIPT_DIR/.docker-build.env"
|
||||
RUNTIME_COMPOSE_OVERRIDE_FILE="$SCRIPT_DIR/.docker-compose.runtime.override.yml"
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--multitenant)
|
||||
@@ -26,10 +28,27 @@ if ! command -v docker >/dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Rebuilding and restarting app container using $COMPOSE_FILE..."
|
||||
docker compose -f "$COMPOSE_FILE" up -d --build app
|
||||
echo "Rebuilding and/or restarting app container using $COMPOSE_FILE..."
|
||||
compose_args=(-f "$COMPOSE_FILE")
|
||||
if [ -f "$RUNTIME_COMPOSE_OVERRIDE_FILE" ]; then
|
||||
compose_args+=( -f "$RUNTIME_COMPOSE_OVERRIDE_FILE" )
|
||||
fi
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
compose_args+=( --env-file "$ENV_FILE" )
|
||||
fi
|
||||
|
||||
if [ -f "$SCRIPT_DIR/Dockerfile" ]; then
|
||||
docker compose "${compose_args[@]}" up -d --build app
|
||||
else
|
||||
echo "Warning: Dockerfile not found in $SCRIPT_DIR. Skipping build and restarting existing app container."
|
||||
if ! docker compose "${compose_args[@]}" up -d --no-build app; then
|
||||
echo "Warning: app image not found or not available locally. Attempting docker compose pull app..."
|
||||
docker compose "${compose_args[@]}" pull app
|
||||
docker compose "${compose_args[@]}" up -d --no-build app
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Cleaning up unused Docker images..."
|
||||
docker image prune -f
|
||||
|
||||
echo "App rebuild complete."
|
||||
echo "App restart complete."
|
||||
|
||||
Reference in New Issue
Block a user