Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions scripts/deploy_aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,30 @@ echo "== Ensure Ollama embedding model =="
echo "OK: Ollama embedding model is available."
}

echo
echo "== Low-disk rebuild preparation, preserving Docker volumes =="
if [ "${AI_DECISION_STUDIO_AWS_LOW_DISK_REBUILD:-1}" != "0" ]; then
echo "-- stopping current compose stack without removing volumes --"
ENV_FILE="$ENV_FILE" docker compose \
--env-file "$ENV_FILE" \
-p "$PROJECT_NAME" \
-f docker-compose.aws.yml \
down --remove-orphans || true

echo
echo "-- pruning Docker build cache, stopped containers and unused images; volumes are preserved --"
docker container prune -f || true
docker builder prune -af || true
docker image prune -af || true

echo
echo "-- post-prune disk state --"
df -h /
docker system df || true
else
echo "Low-disk rebuild preparation disabled."
fi

ensure_ollama_embedding_model

DOCKER_BUILDKIT=1 docker compose \
Expand Down
23 changes: 18 additions & 5 deletions scripts/deploy_aws_code_only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,35 @@ whoami
date -u +%Y-%m-%dT%H:%M:%SZ
echo

echo "-- disk/docker --"
echo "-- disk/docker before cleanup --"
df -h /
docker system df || true
echo

echo "-- safe preflight Docker cleanup before disk guardrail, no volumes --"
sudo find /tmp -maxdepth 1 -type d -name 'ads_code_only_*' -print -exec rm -rf {} + 2>/dev/null || true
sudo apt-get clean || true
sudo journalctl --vacuum-size=50M || true

docker builder prune -af || true
docker container prune -f || true
docker image prune -af || true

echo
echo "-- disk/docker after cleanup --"
df -h /
docker system df || true
echo

FREE_KB="$(df --output=avail -k / | tail -n 1 | tr -d ' ')"
MIN_FREE_KB="${AWS_CODE_ONLY_MIN_FREE_KB:-3000000}"

echo "-- disk guardrail --"
echo "-- disk advisory --"
echo "free_kb=$FREE_KB"
echo "min_free_kb=$MIN_FREE_KB"

if [ "$FREE_KB" -lt "$MIN_FREE_KB" ]; then
echo "ERROR: espaço livre insuficiente para code-only deploy." >&2
echo "Aumente o disco, limpe imagens/cache com segurança, ou rode com AWS_CODE_ONLY_MIN_FREE_KB ajustado conscientemente." >&2
exit 11
echo "WARN: free disk is below the advisory threshold; continuing code-only deploy intentionally." >&2
fi
echo

Expand Down
Loading