Files
vscode/test/sanity/scripts/run-docker.sh
Dmitriy Vasyura 141d5452e8 Cache docker images for sanity tests (#290124)
Cache sanity tests docker images in Azure DevOps pipelines
2026-01-24 13:22:34 +01:00

46 lines
1013 B
Bash
Executable File

#!/bin/sh
set -e
CONTAINER=""
ARCH="amd64"
BASE_IMAGE=""
ARGS=""
while [ $# -gt 0 ]; do
case "$1" in
--container) CONTAINER="$2"; shift 2 ;;
--arch) ARCH="$2"; shift 2 ;;
--base-image) BASE_IMAGE="$2"; shift 2 ;;
*) ARGS="$ARGS $1"; shift ;;
esac
done
if [ -z "$CONTAINER" ]; then
echo "Error: --container is required"
exit 1
fi
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
ROOT_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
# Only build if image doesn't exist (i.e., not loaded from cache)
if ! docker image inspect "$CONTAINER" > /dev/null 2>&1; then
echo "Building container image: $CONTAINER"
docker buildx build \
--platform "linux/$ARCH" \
${BASE_IMAGE:+--build-arg "BASE_IMAGE=$BASE_IMAGE"} \
--tag "$CONTAINER" \
--file "$ROOT_DIR/containers/$CONTAINER.dockerfile" \
"$ROOT_DIR/containers"
else
echo "Using cached container image: $CONTAINER"
fi
echo "Running sanity tests in container"
docker run \
--rm \
--platform "linux/$ARCH" \
--volume "$ROOT_DIR:/root" \
"$CONTAINER" \
$ARGS