#!/bin/bash # Script to QA the toolbox-qadocker image using the tools inside it set -e echo "Starting QA of toolbox-qadocker image..." # Test 1: Hadolint - Lint the Dockerfile echo "Testing Dockerfile with Hadolint..." docker run --rm -i -v "$(pwd)":/workspace -w /workspace tsysdevstack-toolboxstack-toolbox-qadocker:dev hadolint --config .hadolint.yaml /workspace/Dockerfile echo "Hadolint check passed!" # Test 2: ShellCheck - Lint shell scripts echo "Testing shell scripts with ShellCheck..." docker run --rm -i -v "$(pwd)":/workspace tsysdevstack-toolboxstack-toolbox-qadocker:dev shellcheck /workspace/build.sh /workspace/run.sh echo "ShellCheck passed!" # Test 3: Trivy - Run a filesystem scan echo "Testing filesystem with Trivy..." # Skip downloading DB for this test by using offline mode docker run --rm -i -v "$(pwd)":/workspace tsysdevstack-toolboxstack-toolbox-qadocker:dev trivy fs --offline-scan /workspace echo "Trivy scan completed!" # Test 4: Use the Docker client to check version (skip daemon connection test) echo "Testing Docker client functionality..." docker run --rm -i tsysdevstack-toolboxstack-toolbox-qadocker:dev docker version 2>/dev/null || echo "Docker client present (version check failed as expected without daemon)" echo "Docker client test passed!" # Test 5: Run the container in interactive mode and check tools echo "Running interactive test..." docker run --rm -i tsysdevstack-toolboxstack-toolbox-qadocker:dev bash -c "which hadolint && which shellcheck && which trivy && which docker && which buildctl && which dockerlint" echo "All tools are properly installed!" # Test 6: Run dockerlint on a sample Dockerfile echo "Testing Dockerlint..." docker run --rm -i -v "$(pwd)":/workspace -w /workspace tsysdevstack-toolboxstack-toolbox-qadocker:dev dockerlint Dockerfile echo "Dockerlint test completed!" echo "All QA tests completed successfully!"