Browse Source

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>
Ricardo Martincoski 3 năm trước cách đây
mục cha
commit
242e9d72e7
1 tập tin đã thay đổi với 10 bổ sung0 xóa
  1. 10 0
      utils/docker-run

+ 10 - 0
utils/docker-run

@@ -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}" "$@"