utils/docker-run: new script

Add a small script to run commands in the same docker image used in the
GitLab CI.

For instance, one can run check-package unit tests without installing
pytest directly in the host:
$ ./utils/docker-run python3 -m pytest -v utils/checkpackagelib/

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Arnout: fix shellcheck errors; add exec]
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This commit is contained in:
Ricardo Martincoski 2022-01-23 13:08:46 -03:00 committed by Arnout Vandecappelle (Essensium/Mind)
parent fcceee0b2e
commit 242e9d72e7

10
utils/docker-run Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/bash
set -o errexit -o pipefail
DIR=$(dirname "${0}")
MAIN_DIR=$(readlink -f "${DIR}/..")
# shellcheck disable=SC2016
IMAGE=$(grep ^image: "${MAIN_DIR}/.gitlab-ci.yml" | \
sed -e 's,^image: ,,g' | sed -e 's,\$CI_REGISTRY,registry.gitlab.com,g')
set -x
exec docker run -v "${MAIN_DIR}:/home/br-user" -t "${IMAGE}" "$@"