#!/usr/bin/env bash # Build all device-inventory images and load them onto the required k8s nodes. # Run this from any machine with Docker and SSH access to the nodes. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" NODE2_IP="192.168.2.195" # kube-node-2 (server + web-ui + cli CronJob) NODE3_IP="192.168.2.196" # kube-node-3 (cli CronJob only) echo "=== Building inventory-server:latest ===" docker build -t inventory-server:latest -f "$SCRIPT_DIR/Dockerfile" "$SCRIPT_DIR" echo "=== Building device-inventory:latest (CLI) ===" docker build -t device-inventory:latest -f "$SCRIPT_DIR/Dockerfile.cli" "$SCRIPT_DIR" echo "=== Building inventory-web-ui:latest ===" docker build -t inventory-web-ui:latest -f "$SCRIPT_DIR/web-ui/Dockerfile" "$SCRIPT_DIR/web-ui" echo "=== Loading images onto kube-node-2 ($NODE2_IP) ===" for img in inventory-server:latest inventory-web-ui:latest device-inventory:latest; do echo " → $img" docker save "$img" | ssh "dan@$NODE2_IP" "sudo ctr --namespace k8s.io images import -" done echo "=== Loading images onto kube-node-3 ($NODE3_IP) ===" for img in inventory-server:latest inventory-web-ui:latest device-inventory:latest; do echo " → $img" docker save "$img" | ssh "dan@$NODE3_IP" "sudo ctr --namespace k8s.io images import -" done echo "" echo "=== All images loaded. Apply the manifest with: ===" echo " kubectl apply -f /home/dan/homelab/deployment/infrastructure/device-inventory.yaml"