Variablize Docker platform

This commit is contained in:
cytopia
2022-03-17 16:10:03 +01:00
parent 2517c33bae
commit 5585109fb8
3 changed files with 62 additions and 56 deletions

View File

@@ -149,13 +149,13 @@ lint-yaml:
gen-readme:
ifeq ($(strip $(VERSION)),)
@echo "Generate README.md for all PHP versions"
cd build; ./gen-readme.sh
cd build; ./gen-readme.sh $(ARCH)
else
@echo "Generate README.md for PHP $(VERSION)"
@$(MAKE) --no-print-directory _check-version
@$(MAKE) --no-print-directory _check-image-exists _EXIST_IMAGE=base
@$(MAKE) --no-print-directory _check-image-exists _EXIST_IMAGE=mods
cd build; ./gen-readme.sh $(VERSION)
cd build; ./gen-readme.sh $(ARCH) $(VERSION)
endif
gen-dockerfiles:
@@ -286,28 +286,28 @@ test-base: _check-version
test-base: _EXIST_IMAGE=base
test-base: _check-image-exists
test-base:
./tests/test.sh ${VERSION} base
./tests/test.sh $(IMAGE) $(ARCH) $(VERSION) base
test-mods: _check-version
test-mods: _EXIST_IMAGE=mods
test-mods: _check-image-exists
test-mods: _check-version
./tests/test.sh ${VERSION} mods
./tests/test.sh $(IMAGE) $(ARCH) $(VERSION) mods
test-prod: _check-version
test-prod: _EXIST_IMAGE=prod
test-prod: _check-image-exists
test-prod: _check-version
./tests/test.sh ${VERSION} prod
./tests/test.sh $(IMAGE) $(ARCH) $(VERSION) prod
test-work: _check-version
test-work: _EXIST_IMAGE=work
test-work: _check-image-exists
test-work: _check-version
./tests/test.sh ${VERSION} work
./tests/test.sh $(IMAGE) $(ARCH) $(VERSION) work
# -------------------------------------------------------------------------------------------------

View File

@@ -8,25 +8,27 @@ set -o pipefail
# Get absolute directory of this script
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
ARCH="${1:-linux/amd64}"
###
### Show Usage
###
print_usage() {
echo "Usage: gen-readme.sh"
echo " gen-readme.sh 5.2"
echo " gen-readme.sh 5.3"
echo " gen-readme.sh 5.4"
echo " gen-readme.sh 5.5"
echo " gen-readme.sh 5.6"
echo " gen-readme.sh 7.0"
echo " gen-readme.sh 7.1"
echo " gen-readme.sh 7.2"
echo " gen-readme.sh 7.3"
echo " gen-readme.sh 7.4"
echo " gen-readme.sh 8.0"
echo " gen-readme.sh 8.1"
echo " gen-readme.sh 8.2"
echo "Usage: gen-readme.sh [<ARCH>]"
echo " gen-readme.sh <ARCH> 5.2"
echo " gen-readme.sh <ARCH> 5.3"
echo " gen-readme.sh <ARCH> 5.4"
echo " gen-readme.sh <ARCH> 5.5"
echo " gen-readme.sh <ARCH> 5.6"
echo " gen-readme.sh <ARCH> 7.0"
echo " gen-readme.sh <ARCH> 7.1"
echo " gen-readme.sh <ARCH> 7.2"
echo " gen-readme.sh <ARCH> 7.3"
echo " gen-readme.sh <ARCH> 7.4"
echo " gen-readme.sh <ARCH> 8.0"
echo " gen-readme.sh <ARCH> 8.1"
echo " gen-readme.sh <ARCH> 8.2"
}
@@ -37,22 +39,22 @@ get_modules() {
tag="${1}"
# Retrieve all modules
PHP_MODULES="$( docker run --rm $(tty -s && echo '-it' || echo) --entrypoint=php devilbox/php-fpm:${tag} -m )"
PHP_MODULES="$( docker run --rm --platform "${ARCH}" $(tty -s && echo '-it' || echo) --entrypoint=php devilbox/php-fpm:${tag} -m )"
ALL_MODULES=
if docker run --rm $(tty -s && echo '-it' || echo) --entrypoint=find devilbox/php-fpm:${tag} /usr/local/lib/php/extensions -name 'ioncube.so' | grep -q ioncube.so; then
if docker run --rm --platform "${ARCH}" $(tty -s && echo '-it' || echo) --entrypoint=find devilbox/php-fpm:${tag} /usr/local/lib/php/extensions -name 'ioncube.so' | grep -q ioncube.so; then
ALL_MODULES="${ALL_MODULES},ioncube";
fi
if docker run --rm $(tty -s && echo '-it' || echo) --entrypoint=find devilbox/php-fpm:${tag} /usr/local/lib/php/extensions -name 'blackfire.so' | grep -q blackfire.so; then
if docker run --rm --platform "${ARCH}" $(tty -s && echo '-it' || echo) --entrypoint=find devilbox/php-fpm:${tag} /usr/local/lib/php/extensions -name 'blackfire.so' | grep -q blackfire.so; then
ALL_MODULES="${ALL_MODULES},blackfire";
fi
if docker run --rm $(tty -s && echo '-it' || echo) --entrypoint=find devilbox/php-fpm:${tag} /usr/local/lib/php/extensions -name 'psr.so' | grep -q psr.so; then
if docker run --rm --platform "${ARCH}" $(tty -s && echo '-it' || echo) --entrypoint=find devilbox/php-fpm:${tag} /usr/local/lib/php/extensions -name 'psr.so' | grep -q psr.so; then
ALL_MODULES="${ALL_MODULES},psr";
fi
if docker run --rm $(tty -s && echo '-it' || echo) --entrypoint=find devilbox/php-fpm:${tag} /usr/local/lib/php/extensions -name 'phalcon.so' | grep -q phalcon.so; then
if docker run --rm --platform "${ARCH}" $(tty -s && echo '-it' || echo) --entrypoint=find devilbox/php-fpm:${tag} /usr/local/lib/php/extensions -name 'phalcon.so' | grep -q phalcon.so; then
ALL_MODULES="${ALL_MODULES},phalcon";
fi
@@ -91,7 +93,7 @@ update_readme() {
###
### Entrypoint
###
if [ "${#}" -eq "0" ]; then
if [ "${#}" -eq "0" ] || [ "${#}" -eq "1" ]; then
# Update PHP modules for all versions at once
update_readme "5.2"
update_readme "5.3"
@@ -106,31 +108,31 @@ if [ "${#}" -eq "0" ]; then
update_readme "8.0"
update_readme "8.1"
update_readme "8.2"
elif [ "${#}" -gt "1" ]; then
elif [ "${#}" -gt "2" ]; then
# Specifying more than 1 argument is wrong
echo "Error, invalid number of arguments."
print_usage
exit 1
else
if [ "${1}" != "5.2" ] \
&& [ "${1}" != "5.3" ] \
&& [ "${1}" != "5.4" ] \
&& [ "${1}" != "5.5" ] \
&& [ "${1}" != "5.6" ] \
&& [ "${1}" != "7.0" ] \
&& [ "${1}" != "7.1" ] \
&& [ "${1}" != "7.2" ] \
&& [ "${1}" != "7.3" ] \
&& [ "${1}" != "7.4" ] \
&& [ "${1}" != "8.0" ] \
&& [ "${1}" != "8.1" ] \
&& [ "${1}" != "8.2" ]; then
if [ "${2}" != "5.2" ] \
&& [ "${2}" != "5.3" ] \
&& [ "${2}" != "5.4" ] \
&& [ "${2}" != "5.5" ] \
&& [ "${2}" != "5.6" ] \
&& [ "${2}" != "7.0" ] \
&& [ "${2}" != "7.1" ] \
&& [ "${2}" != "7.2" ] \
&& [ "${2}" != "7.3" ] \
&& [ "${2}" != "7.4" ] \
&& [ "${2}" != "8.0" ] \
&& [ "${2}" != "8.1" ] \
&& [ "${2}" != "8.2" ]; then
# Argument does not match any of the PHP versions
echo "Error, invalid argument."
print_usage
exit 1
else
# Update PHP modules for one specific PHP version
update_readme "${1}"
update_readme "${2}"
fi
fi

View File

@@ -16,7 +16,6 @@ IFS=$'\n'
###
### Variables
###
# Current directory
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
@@ -31,51 +30,56 @@ CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
###
### Sanity check
###
if [ "${#}" -ne "2" ]; then
echo "Usage: start.ci <version> <flavour>"
if [ "${#}" -ne "4" ]; then
echo "Usage: start.ci <image> <arch> <version> <flavour>"
exit 1
fi
IMAGE="${1}"
ARCH="${2}"
VERSION="${3}"
FLAVOUR="${4}"
###
### Run tests
###
if [ "${2}" = "base" ] || [ "${2}" = "mods" ] || [ "${2}" = "prod" ] || [ "${2}" = "work" ]; then
if [ "${FLAVOUR}" = "base" ] || [ "${FLAVOUR}" = "mods" ] || [ "${FLAVOUR}" = "prod" ] || [ "${FLAVOUR}" = "work" ]; then
TESTS="$( find ${CWD} -regex "${CWD}/base/[0-9].+.*\.sh" | sort -u )"
for t in ${TESTS}; do
printf "\n\n\033[0;33m%s\033[0m\n" "################################################################################"
printf "\033[0;33m%s %s\033[0m\n" "#" "[${1}-${2}]: ${t}"
printf "\033[0;33m%s %s\033[0m\n" "#" "[${VERSION}-${FLAVOUR}] (${ARCH}): ${t}"
printf "\033[0;33m%s\033[0m\n\n" "################################################################################"
time ${t} devilbox/php-fpm ${1} ${2}
time ${t} "${IMAGE}" "${VERSION}" "${FLAVOUR}"
done
fi
if [ "${2}" = "mods" ] || [ "${2}" = "prod" ] || [ "${2}" = "work" ]; then
if [ "${FLAVOUR}" = "mods" ] || [ "${FLAVOUR}" = "prod" ] || [ "${FLAVOUR}" = "work" ]; then
TESTS="$( find ${CWD} -regex "${CWD}/mods/[0-9].+.*\.sh" | sort -u )"
for t in ${TESTS}; do
printf "\n\n\033[0;33m%s\033[0m\n" "################################################################################"
printf "\033[0;33m%s %s\033[0m\n" "#" "[${1}-${2}]: ${t}"
printf "\033[0;33m%s %s\033[0m\n" "#" "[${VERSION}-${FLAVOUR}] (${ARCH}): ${t}"
printf "\033[0;33m%s\033[0m\n\n" "################################################################################"
time ${t} devilbox/php-fpm ${1} ${2}
time ${t} "${IMAGE}" "${VERSION}" "${FLAVOUR}"
done
fi
if [ "${2}" = "prod" ] || [ "${2}" = "work" ]; then
if [ "${FLAVOUR}" = "prod" ] || [ "${FLAVOUR}" = "work" ]; then
TESTS="$( find ${CWD} -regex "${CWD}/prod/[0-9].+.*\.sh" | sort -u )"
for t in ${TESTS}; do
printf "\n\n\033[0;33m%s\033[0m\n" "################################################################################"
printf "\033[0;33m%s %s\033[0m\n" "#" "[${1}-${2}]: ${t}"
printf "\033[0;33m%s %s\033[0m\n" "#" "[${VERSION}-${FLAVOUR}] (${ARCH}): ${t}"
printf "\033[0;33m%s\033[0m\n\n" "################################################################################"
time ${t} devilbox/php-fpm ${1} ${2}
time ${t} "${IMAGE}" "${VERSION}" "${FLAVOUR}"
done
fi
if [ "${2}" = "work" ]; then
if [ "${FLAVOUR}" = "work" ]; then
TESTS="$( find ${CWD} -regex "${CWD}/work/[0-9].+.*\.sh" | sort -u )"
for t in ${TESTS}; do
printf "\n\n\033[0;33m%s\033[0m\n" "################################################################################"
printf "\033[0;33m%s %s\033[0m\n" "#" "[${1}-${2}]: ${t}"
printf "\033[0;33m%s %s\033[0m\n" "#" "[${VERSION}-${FLAVOUR}] (${ARCH}): ${t}"
printf "\033[0;33m%s\033[0m\n\n" "################################################################################"
time ${t} devilbox/php-fpm ${1} ${2}
time ${t} "${IMAGE}" "${VERSION}" "${FLAVOUR}"
done
fi