#!/usr/bin/env bash

# The directory of this script is also EMPER's root directory.
EMPER_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

IMAGE=$(sed --regexp-extended --quiet 's;^image: "([^"]*)"$;\1;p' "${EMPER_ROOT}/.gitlab-ci.yml")

docker run \
	   --volume="${EMPER_ROOT}:${EMPER_ROOT}" \
	   --interactive \
	   --tty \
	   --env USER_ID="${UID}" \
	   --env GROUP_ID="$(id -g ${USER})" \
	   --security-opt=seccomp:unconfined \
	   "${IMAGE}" \
	   "${EMPER_ROOT}/tools/docker-prepare" "${EMPER_ROOT}" $@