mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-22 07:16:14 +01:00

[TASK] Streamline container binary chain (#1279)

First iteration of the `Build/Scripts/runTests.sh` supporting
`docker` and `podman` introduced a switch for direct usage in
local environments while keeping `docker` as strong default.

This change removes the hardcoded default for local and ci runs
and introduces a detection of available binaries, prefering the
`podman` over `docker` if both are installed on the host and no
specific binary selected using `-b <container-bin>`.

If no specific binary is provided, the detection chain is now:

* podman
* docker

Default binary variables are removed due to beeing obsolete now.

Resolves: #1148
This commit is contained in:
Stefan Bürk 2024-05-07 12:13:20 +02:00 committed by GitHub
parent 188303fed1
commit 6bad0fbac7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -280,7 +280,7 @@ Examples:
EOF EOF
} }
# Test if docker exists, else exit out with error # Test if at least one of the supported container binaries exists, else exit out with error
if ! type "docker" >/dev/null 2>&1 && ! type "podman" >/dev/null 2>&1; then if ! type "docker" >/dev/null 2>&1 && ! type "podman" >/dev/null 2>&1; then
echo "This script relies on docker or podman. Please install at least one of them" >&2 echo "This script relies on docker or podman. Please install at least one of them" >&2
exit 1 exit 1
@ -306,8 +306,6 @@ PHPUNIT_RANDOM=""
CGLCHECK_DRY_RUN=0 CGLCHECK_DRY_RUN=0
DATABASE_DRIVER="" DATABASE_DRIVER=""
CONTAINER_BIN="" CONTAINER_BIN=""
DEFAULT_CONTAINER_BIN="docker"
DEFAULT_CI_CONTAINER_BIN="docker"
COMPOSER_ROOT_VERSION="3.0.x-dev" COMPOSER_ROOT_VERSION="3.0.x-dev"
CONTAINER_INTERACTIVE="-it --init" CONTAINER_INTERACTIVE="-it --init"
HOST_UID=$(id -u) HOST_UID=$(id -u)
@ -407,16 +405,16 @@ handleDbmsOptions
if [ "${CI}" == "true" ]; then if [ "${CI}" == "true" ]; then
IS_CORE_CI=1 IS_CORE_CI=1
CONTAINER_INTERACTIVE="" CONTAINER_INTERACTIVE=""
# set default ci container binary, if not set using "-b" option
if [ "${CONTAINER_BIN}" == "" ]; then
CONTAINER_BIN="${DEFAULT_CI_CONTAINER_BIN}"
fi
CI_PARAMS="--pull=never" CI_PARAMS="--pull=never"
fi fi
# set default container binary, if not set using "-b" option # determine default container binary to use: 1. podman 2. docker
if [ "${CONTAINER_BIN}" == "" ]; then if [[ -z "${CONTAINER_BIN}" ]]; then
CONTAINER_BIN="${DEFAULT_CONTAINER_BIN}" if type "podman" >/dev/null 2>&1; then
CONTAINER_BIN="podman"
elif type "docker" >/dev/null 2>&1; then
CONTAINER_BIN="docker"
fi
fi fi
if [ $(uname) != "Darwin" ] && [ "${CONTAINER_BIN}" == "docker" ]; then if [ $(uname) != "Darwin" ] && [ "${CONTAINER_BIN}" == "docker" ]; then