From 522508cb74c3c65ac3a1867475a97a0ac12e556e Mon Sep 17 00:00:00 2001 From: Francesco Albano Date: Fri, 23 May 2025 01:39:07 +0200 Subject: [PATCH] Refactor ci-build.sh to use dynamic NODE_IP and improve registry check message; remove test header from index.html --- ci-build.sh | 27 +++++++++++++++++---------- frontend/index.html | 1 - 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ci-build.sh b/ci-build.sh index 168357f..f9c7204 100755 --- a/ci-build.sh +++ b/ci-build.sh @@ -1,13 +1,16 @@ #!/bin/bash # Script per buildare e pushare le immagini al registry locale -# Variabili -REGISTRY="localhost:5000" -TAG=$(date +%Y%m%d-%H%M%S) # Usa timestamp come tag +NODE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[0].address}') -# Verifica che il registry locale sia in esecuzione -if ! curl -s http://localhost:5000/v2/ > /dev/null; then - echo "❌ Registry localhost:5000 non raggiungibile. Avvialo con: docker run -d -p 5000:5000 registry:2" +# Variabili +REGISTRY="localhost:5000" +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 fi @@ -26,9 +29,9 @@ docker push $REGISTRY/worker:$TAG # Aggiorna i file YAML di Kubernetes echo "📝 Updating Kubernetes manifests..." -sed -i "s|localhost:5000/backend:latest|$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/worker:latest|$REGISTRY/worker:$TAG|g" k8s/worker.yaml +sed -i "s|localhost:5000/backend:.*|${REGISTRY}/backend:${TAG}|g" k8s/backend.yaml +sed -i "s|localhost:5000/frontend:.*|${REGISTRY}/frontend:${TAG}|g" k8s/frontend.yaml +sed -i "s|localhost:5000/worker:.*|${REGISTRY}/worker:${TAG}|g" k8s/worker.yaml # Commit e push a Gitea se necessario if [ "$1" == "--push" ]; then @@ -36,8 +39,12 @@ if [ "$1" == "--push" ]; then git add k8s/ git commit -m "Update images to tag $TAG" git push + + # Sincronizza automaticamente dopo il push + echo "🔄 Sincronizzando automaticamente con ArgoCD..." + argocd app sync k8-mini-app --server=$ARGOCD_SERVER --insecure fi echo "✅ Build completato. Immagini taggate come: $TAG" echo "📋 Per applicare le modifiche manualmente: kubectl apply -f k8s/" -echo "🔄 Per sincronizzare con Argo CD: argocd app sync k8-mini-app" \ No newline at end of file +echo "🔄 Per sincronizzare con Argo CD: argocd app sync k8-mini-app --server=$ARGOCD_SERVER --insecure" \ No newline at end of file diff --git a/frontend/index.html b/frontend/index.html index cd2c1f3..0bbf233 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -28,7 +28,6 @@

Mini Frontend

-

Test CI