#!/usr/bin/env bash # Smoke-test skeleton. Optional, but CI runs it whenever it exists and is # executable, so it is the cheapest place to assert what the image promises. # # Usage: test.sh [image-ref] set -euo pipefail REF="${1:?usage: test.sh }" echo "==> smoke-testing ${REF}" # Run the checks in one container. Mirror the securityContext the image is # actually deployed with, so CI catches read-only or non-root breakage. docker run --rm --interactive \ --read-only \ --tmpfs /tmp:rw,size=64m \ "$REF" bash -s <<'INNER' set -uo pipefail fail=0 ok() { printf ' \033[32mok\033[0m %s\n' "$1"; } bad() { printf ' \033[31mFAIL\033[0m %s\n' "$1"; fail=1; } for t in bash; do command -v "$t" >/dev/null 2>&1 && ok "$t" || bad "$t (not on PATH)" done [ "$fail" = 0 ] && echo "all checks passed" || echo "FAILURES above" exit "$fail" INNER