Files
ht-docker-tools/test-images.sh
Juergen Kunz a15dc3f672 feat: restructure ht-docker-tools repository with enhanced Deno support and NVM integration
- Removed Dockerfile and added multiple Dockerfiles for various tools (ClickHouse, MongoDB, MinIO, Caddy, Redis) with Deno runtime.
- Updated package.json to reflect new repository structure and versioning.
- Added comprehensive README and technical notes for architecture overview and usage.
- Implemented build and test scripts for streamlined image creation and validation.
- Introduced bash scripts for NVM functionality in Docker images.
2025-11-27 13:10:00 +00:00

147 lines
3.7 KiB
Bash

#!/bin/bash
set -e
echo "Testing ht-docker-tools 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 command=$3
echo -e "${BLUE}Testing: ${NC}${description}"
echo -e "${YELLOW} Image: ${NC}${tag}"
echo -e "${YELLOW} Command: ${NC}${command}"
if output=$(docker run --rm "${tag}" bash -c "${command}" 2>&1); then
echo -e "${GREEN} Result: ${NC}${output}"
echo -e "${GREEN} PASSED${NC}"
else
echo -e "${RED} FAILED: ${NC}${output}"
((FAILED_TESTS++))
fi
echo ""
}
echo -e "${BLUE}======================================${NC}"
echo -e "${BLUE}Testing Official Base Images${NC}"
echo -e "${BLUE}======================================${NC}"
echo ""
# Test official base images (Deno only)
test_image "ht-docker-tools:clickhouse" \
"ClickHouse + Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:mongodb" \
"MongoDB + Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:minio" \
"MinIO + Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:caddy" \
"Caddy + Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:redis" \
"Redis + Deno" \
"deno --version | head -1"
echo -e "${BLUE}======================================${NC}"
echo -e "${BLUE}Testing Alpine Images${NC}"
echo -e "${BLUE}======================================${NC}"
echo ""
# Test Alpine images (NVM + Node.js + Deno + Service)
test_image "ht-docker-tools:clickhouse-alpine" \
"ClickHouse Alpine - NVM" \
"nvm --version"
test_image "ht-docker-tools:clickhouse-alpine" \
"ClickHouse Alpine - Node.js" \
"node --version"
test_image "ht-docker-tools:clickhouse-alpine" \
"ClickHouse Alpine - Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:mongodb-alpine" \
"MongoDB Alpine - NVM" \
"nvm --version"
test_image "ht-docker-tools:mongodb-alpine" \
"MongoDB Alpine - Node.js" \
"node --version"
test_image "ht-docker-tools:mongodb-alpine" \
"MongoDB Alpine - Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:minio-alpine" \
"MinIO Alpine - NVM" \
"nvm --version"
test_image "ht-docker-tools:minio-alpine" \
"MinIO Alpine - Node.js" \
"node --version"
test_image "ht-docker-tools:minio-alpine" \
"MinIO Alpine - Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:caddy-alpine" \
"Caddy Alpine - NVM" \
"nvm --version"
test_image "ht-docker-tools:caddy-alpine" \
"Caddy Alpine - Node.js" \
"node --version"
test_image "ht-docker-tools:caddy-alpine" \
"Caddy Alpine - Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:redis-alpine" \
"Redis Alpine - NVM" \
"nvm --version"
test_image "ht-docker-tools:redis-alpine" \
"Redis Alpine - Node.js" \
"node --version"
test_image "ht-docker-tools:redis-alpine" \
"Redis Alpine - Deno" \
"deno --version | head -1"
echo -e "${BLUE}======================================${NC}"
echo -e "${BLUE}Testing NVM Version Switching${NC}"
echo -e "${BLUE}======================================${NC}"
echo ""
test_image "ht-docker-tools:redis-alpine" \
"NVM - Install Node 18" \
"nvm install 18 && nvm use 18 && node --version"
# Summary
echo -e "${BLUE}======================================${NC}"
if [ $FAILED_TESTS -eq 0 ]; then
echo -e "${GREEN}All tests passed!${NC}"
else
echo -e "${RED}${FAILED_TESTS} test(s) failed${NC}"
exit 1
fi
echo -e "${BLUE}======================================${NC}"