2023-12-01 11:40:23 +01:00
|
|
|
#!/bin/bash -e
|
2021-04-01 08:49:44 +02:00
|
|
|
# To build PHP 8 snapshots out of master: doc/docker/fpm/build.sh 8.0 21.1.<date> master
|
2019-07-19 10:07:43 +02:00
|
|
|
|
2021-03-24 08:53:49 +01:00
|
|
|
cd $(dirname $0)
|
|
|
|
|
2024-09-05 10:22:47 +02:00
|
|
|
DEFAULT_PHP_VERSION=8.3
|
2021-03-24 08:53:49 +01:00
|
|
|
PHP_VERSION=$DEFAULT_PHP_VERSION
|
2023-12-01 11:40:23 +01:00
|
|
|
BASE=ubuntu:20.04
|
2023-04-07 12:24:04 +02:00
|
|
|
# which architectures to build for multi-platform images, if buildx is available on a Docker desktop or newer Docker installation
|
|
|
|
PLATFORMS=linux/amd64,linux/ppc64le,linux/arm/v7,linux/arm64/v8
|
2021-03-24 08:53:49 +01:00
|
|
|
|
|
|
|
if [[ $1 =~ ^[78]\.[0-9]$ ]]
|
|
|
|
then
|
|
|
|
PHP_VERSION=$1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2019-08-09 18:31:43 +02:00
|
|
|
DEFAULT=$(git branch|grep ^*|cut -c3-)
|
|
|
|
TAG=${1:-$DEFAULT}
|
2021-04-01 08:49:44 +02:00
|
|
|
VERSION=${2:-$TAG}
|
2019-08-09 18:31:43 +02:00
|
|
|
BRANCH=$(echo $VERSION|sed 's/\.[0-9]\{8\}$//')
|
2021-04-01 08:49:44 +02:00
|
|
|
[ $VERSION = $BRANCH ] && VERSION="dev-$BRANCH"
|
2019-07-19 10:07:43 +02:00
|
|
|
|
2021-04-01 08:49:44 +02:00
|
|
|
[ $VERSION = "dev-$DEFAULT" ] && (
|
|
|
|
cd ../../..
|
|
|
|
composer update 'egroupware/*'
|
2019-07-19 10:07:43 +02:00
|
|
|
git status composer.lock|grep composer.lock && {
|
|
|
|
git stash; git pull --rebase; git stash pop
|
|
|
|
git commit -m 'updating composer.lock with latest commit hashed for egroupware/* packages' composer.lock
|
2019-08-09 18:31:43 +02:00
|
|
|
VERSION="$VERSION#$(git push|grep $DEFAULT|cut -c4-10)"
|
2019-07-19 10:07:43 +02:00
|
|
|
}
|
2021-04-01 08:49:44 +02:00
|
|
|
)
|
2019-07-19 10:07:43 +02:00
|
|
|
|
2021-03-24 08:53:49 +01:00
|
|
|
# add PHP_VERSION to TAG, if not the default PHP version
|
|
|
|
[ $PHP_VERSION != $DEFAULT_PHP_VERSION ] && TAG=$TAG-$PHP_VERSION
|
2019-07-19 10:07:43 +02:00
|
|
|
|
2023-12-01 11:40:23 +01:00
|
|
|
docker pull $BASE
|
2023-04-07 12:24:04 +02:00
|
|
|
|
|
|
|
# add further tags for default PHP version only
|
|
|
|
[ $PHP_VERSION = $DEFAULT_PHP_VERSION -a "$BRANCH" != $VERSION -a "dev-${BRANCH}" != $VERSION ] && {
|
2023-04-12 17:14:54 +02:00
|
|
|
extra_tags="--tag egroupware/egroupware:latest --tag egroupware/egroupware:$BRANCH"
|
2023-04-07 12:24:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if docker buildx 2>&1 >/dev/null
|
|
|
|
then
|
|
|
|
# buildx available --> build a multi-platform image and push it for all tags
|
|
|
|
docker buildx build --push --platform $PLATFORMS --build-arg "VERSION=$VERSION" --build-arg "PHP_VERSION=$PHP_VERSION" --tag egroupware/egroupware:$TAG $extra_tags .
|
|
|
|
else
|
|
|
|
# no buildx, eg. on dev only builds amd64!
|
|
|
|
docker build --build-arg "VERSION=$VERSION" --build-arg "PHP_VERSION=$PHP_VERSION" --tag egroupware/egroupware:$TAG . && {
|
|
|
|
docker push egroupware/egroupware:$TAG
|
2023-04-12 17:14:54 +02:00
|
|
|
for tag in $extra_tags
|
2023-04-07 12:24:04 +02:00
|
|
|
do
|
|
|
|
[ -z "$tag" -o "$tag" = "--tags" ] || {
|
|
|
|
docker tag egroupware/egroupware:$TAG $tag
|
|
|
|
docker push $tag
|
|
|
|
}
|
|
|
|
done
|
|
|
|
}
|
2024-09-05 10:22:47 +02:00
|
|
|
fi
|