Skip to content

Commit

Permalink
run-in-docker.sh: add (temporary) debug checkmarks
Browse files Browse the repository at this point in the history
Change-Id: I4b9b5dbf3d9d3e2ce77483188fd880c9891f7ded
  • Loading branch information
Frans Fürst committed Sep 19, 2024
1 parent 29b2c7d commit 6e87242
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions scripts/run-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ set -e

CHECKOUT_ROOT="$(git rev-parse --show-toplevel)"

echo >&2 "run-in-docker.sh checkpoint 1"

: "${IMAGE_ID:="$(
if [ -n "${IMAGE_ALIAS}" ]; then
"${CHECKOUT_ROOT}"/buildscripts/docker_image_aliases/resolve.py "${IMAGE_ALIAS}"
Expand All @@ -32,8 +34,12 @@ CHECKOUT_ROOT="$(git rev-parse --show-toplevel)"
fi
)"}"

echo >&2 "run-in-docker.sh checkpoint 2 $IMAGE_ID"

IMAGE_VERSION="$(docker run --rm -v "${CHECKOUT_ROOT}/omd:/tmp" "${IMAGE_ID}" /tmp/distro '-')"

echo >&2 "run-in-docker.sh checkpoint 3 $IMAGE_VERSION"

# in case of worktrees $CHECKOUT_ROOT might not contain the actual repository clone
GIT_COMMON_DIR="$(realpath "$(git rev-parse --git-common-dir)")"

Expand Down Expand Up @@ -110,8 +116,25 @@ if [ -t 0 ]; then
echo "Running in Docker container from image ${IMAGE_ID} (cmd=${CMD}) (workdir=${PWD})"
fi

echo >&2 "run-in-docker.sh checkpoint 4"

function cleanup {
echo >&2 "run-in-docker.sh checkpoint 5 $(cat "$CONTAINER_NAME.cid" || echo CID_FILE_NOT_FOUND)"
rm -f "$CONTAINER_NAME.cid"

# FIXME: eventually created image is not being cleaned up

ROOT_ARTIFACTS=$(find . -user root)
if [ -n "${ROOT_ARTIFACTS}" ]; then
echo >&2 "WARNING: there are files/directories owned by root:"
echo >&2 "${ROOT_ARTIFACTS}"
fi
}
trap cleanup EXIT

# shellcheck disable=SC2086
docker run -a stdout -a stderr \
--cidfile "$CONTAINER_NAME.cid" \
--rm \
--name $CONTAINER_NAME \
${TERMINAL_FLAG} \
Expand Down Expand Up @@ -144,11 +167,3 @@ docker run -a stdout -a stderr \
${DOCKER_RUN_ADDOPTS} \
"${IMAGE_ID}" \
sh -c "${CMD}"

# FIXME: eventually created image is not being cleaned up

ROOT_ARTIFACTS=$(find . -user root)
if [ -n "${ROOT_ARTIFACTS}" ]; then
echo >&2 "WARNING: there are files/directories owned by root:"
echo >&2 "${ROOT_ARTIFACTS}"
fi

0 comments on commit 6e87242

Please sign in to comment.