Refactor ci-build.sh to use dynamic NODE_IP and improve registry check message; remove test header from index.html

This commit is contained in:
Francesco Albano 2025-05-23 01:39:07 +02:00
parent 470dec6e8a
commit 522508cb74
2 changed files with 17 additions and 11 deletions

View File

@ -1,13 +1,16 @@
#!/bin/bash #!/bin/bash
# Script per buildare e pushare le immagini al registry locale # Script per buildare e pushare le immagini al registry locale
# Variabili NODE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[0].address}')
REGISTRY="localhost:5000"
TAG=$(date +%Y%m%d-%H%M%S) # Usa timestamp come tag
# Verifica che il registry locale sia in esecuzione # Variabili
if ! curl -s http://localhost:5000/v2/ > /dev/null; then REGISTRY="localhost:5000"
echo "❌ Registry localhost:5000 non raggiungibile. Avvialo con: docker run -d -p 5000:5000 registry:2" TAG=$(date +%Y%m%d-%H%M%S)
ARGOCD_SERVER="${NODE_IP}:30080"
# Verifica che il registry sia in esecuzione
if ! curl -s http://${NODE_IP}:5000/v2/ > /dev/null; then
echo "❌ Registry ${NODE_IP}:5000 non raggiungibile."
exit 1 exit 1
fi fi
@ -26,9 +29,9 @@ docker push $REGISTRY/worker:$TAG
# Aggiorna i file YAML di Kubernetes # Aggiorna i file YAML di Kubernetes
echo "📝 Updating Kubernetes manifests..." echo "📝 Updating Kubernetes manifests..."
sed -i "s|localhost:5000/backend:latest|$REGISTRY/backend:$TAG|g" k8s/backend.yaml sed -i "s|localhost:5000/backend:.*|${REGISTRY}/backend:${TAG}|g" k8s/backend.yaml
sed -i "s|localhost:5000/frontend:latest|$REGISTRY/frontend:$TAG|g" k8s/frontend.yaml sed -i "s|localhost:5000/frontend:.*|${REGISTRY}/frontend:${TAG}|g" k8s/frontend.yaml
sed -i "s|localhost:5000/worker:latest|$REGISTRY/worker:$TAG|g" k8s/worker.yaml sed -i "s|localhost:5000/worker:.*|${REGISTRY}/worker:${TAG}|g" k8s/worker.yaml
# Commit e push a Gitea se necessario # Commit e push a Gitea se necessario
if [ "$1" == "--push" ]; then if [ "$1" == "--push" ]; then
@ -36,8 +39,12 @@ if [ "$1" == "--push" ]; then
git add k8s/ git add k8s/
git commit -m "Update images to tag $TAG" git commit -m "Update images to tag $TAG"
git push git push
# Sincronizza automaticamente dopo il push
echo "🔄 Sincronizzando automaticamente con ArgoCD..."
argocd app sync k8-mini-app --server=$ARGOCD_SERVER --insecure
fi fi
echo "✅ Build completato. Immagini taggate come: $TAG" echo "✅ Build completato. Immagini taggate come: $TAG"
echo "📋 Per applicare le modifiche manualmente: kubectl apply -f k8s/" echo "📋 Per applicare le modifiche manualmente: kubectl apply -f k8s/"
echo "🔄 Per sincronizzare con Argo CD: argocd app sync k8-mini-app" echo "🔄 Per sincronizzare con Argo CD: argocd app sync k8-mini-app --server=$ARGOCD_SERVER --insecure"

View File

@ -28,7 +28,6 @@
</head> </head>
<body> <body>
<h1>Mini Frontend</h1> <h1>Mini Frontend</h1>
<h2>Test CI</h2>
<button onclick="sendMessage()">Invia Messaggio</button> <button onclick="sendMessage()">Invia Messaggio</button>
<button onclick="retrieveMessage()">Recupera Messaggio</button> <button onclick="retrieveMessage()">Recupera Messaggio</button>
<button onclick="checkQueueInfo()">Verifica Stato Coda</button> <button onclick="checkQueueInfo()">Verifica Stato Coda</button>