This is a wrapper around docker exec
that makes sure to set up a matching user; it also has a pre-script hook. It's kind of janky but it was useful.
It's a lot like Microsoft's `wsl -- command'
Originally written as part of https://github.com/neuropoly/spinalcordtoolbox/blob/916ab591ca2e35cab9f5f27ec2439ce8fdb0b9d2/util/dockerize.sh but that project migrated to Github Actions.
We used it like this:
# if this is a docker job, run in the container instead; but if not just run it here.
if [ -n "${DOCKER_IMAGE:-}" ]; then
./util/dockerize.sh ./.ci.sh
elif [ "${TRAVIS_OS_NAME:-}" = "windows" ]; then
choco install wsl-ubuntu-1804 -y --ignore-checksums
# or, instead of choco, use curl + powershell:
# https://docs.microsoft.com/en-us/windows/wsl/install-manual#downloading-distros-via-the-command-line
# wsl --setdefault "Ubuntu-18.04"
# TODO: Travis's version of wsl is too old for --setdefault.
# Instead we trust that wsl will default to the installed
# Ubuntu because it is the only option, but it would be
# better to be explicit when it becomes possible.
# disable apt's helpful (and build-breaking) interactive mode
# https://linuxhint.com/debian_frontend_noninteractive/
export DEBIAN_FRONTEND="noninteractive"
# Use WSLENV to actually pass it into WSL
# https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows/
export WSLENV=DEBIAN_FRONTEND
wsl apt-get update
#wsl apt-get -y upgrade # this step is probably important, but it's also sooo slow
wsl apt-get install -y gcc git curl
wsl ./.ci.sh
else
./.ci.