#!/usr/bin/env 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') declare -a docker_opts=( -i --rm --user "$(id -u):$(id -g)" --mount "type=bind,src=${MAIN_DIR},dst=${MAIN_DIR}" --workdir "${MAIN_DIR}" ) if tty -s; then docker_opts+=( -t ) fi exec docker run "${docker_opts[@]}" "${IMAGE}" "${@}"