#!/bin/bash set -e echo "๐Ÿงช Testing Multi-Architecture Alpine Docker Images" echo "===================================================" echo "" # Color codes GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' # No Color FAILED_TESTS=0 # Test function test_image() { local tag=$1 local description=$2 local test_cmd=$3 echo -e "${BLUE}๐Ÿงช Testing: ${NC}${description}" echo -e "${YELLOW} Tag: ${NC}${tag}" if docker run --rm "${tag}" bash -c "${test_cmd}"; then echo -e "${GREEN}โœ… Pass${NC}" echo "" return 0 else echo -e "${RED}โŒ Fail${NC}" echo "" ((FAILED_TESTS++)) return 1 fi } # Test Alpine Images (Native Platform) echo -e "${BLUE}โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}" echo -e "${BLUE}Testing Alpine Images (Native Platform)${NC}" echo -e "${BLUE}โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}" echo "" echo -e "${YELLOW}๐Ÿ’ก These images are built for your native architecture${NC}" echo -e "${YELLOW} They will run at full native speed without emulation${NC}" echo "" test_image "ht-docker-node:alpine-node" \ "Alpine with Node.js LTS + NVM + pnpm" \ "nvm --version && node --version && pnpm --version" test_image "ht-docker-node:alpine-deno" \ "Alpine with Node.js LTS + NVM + Deno" \ "nvm --version && node --version && deno --version" test_image "ht-docker-node:alpine-bun" \ "Alpine with Node.js LTS + NVM + Bun" \ "nvm --version && node --version && bun --version" # Test NVM version switching (critical feature) echo -e "${BLUE}โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}" echo -e "${BLUE}Testing NVM Version Switching${NC}" echo -e "${BLUE}โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}" echo "" test_image "ht-docker-node:alpine-node" \ "NVM version switching" \ "node --version && nvm install 18 && node --version | grep v18" # Summary echo -e "${BLUE}โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}" if [ $FAILED_TESTS -eq 0 ]; then echo -e "${GREEN}โœจ All Tests Passed! (0 failures)${NC}" echo -e "${BLUE}โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}" echo "" echo -e "${YELLOW}๐Ÿ’ก In production, these same images will work natively on both amd64 and arm64${NC}" echo "" exit 0 else echo -e "${RED}โŒ Some Tests Failed (${FAILED_TESTS} failures)${NC}" echo -e "${BLUE}โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}" echo "" exit 1 fi