2023-01-16 23:17:11 +01:00
|
|
|
#!/bin/bash -xe
|
2019-11-06 22:26:30 +01:00
|
|
|
|
2019-11-30 14:32:49 +01:00
|
|
|
REPO=egroupware
|
|
|
|
IMAGE=development
|
2023-11-12 07:51:56 +01:00
|
|
|
BASE=ubuntu:20.04
|
2022-05-11 08:46:53 +02:00
|
|
|
RECOMMENDED_PHP_VERSION=8.1
|
2019-11-30 14:32:49 +01:00
|
|
|
|
2022-05-11 08:46:53 +02:00
|
|
|
PHP_VERSION=${1:-8.1}
|
2019-11-30 14:32:49 +01:00
|
|
|
|
2023-01-16 23:17:11 +01:00
|
|
|
TAG=$(docker run --rm -i --entrypoint bash $REPO/$IMAGE:latest -c "apt update && apt search php$PHP_VERSION-fpm" 2>/dev/null|grep php$PHP_VERSION-fpm|sed "s|^php$PHP_VERSION-fpm/[^ ]* .*\([78]\.[0-9]*\.[0-9]*\).*|\1|g")
|
2019-11-30 14:32:49 +01:00
|
|
|
test -z "$TAG" && {
|
|
|
|
echo "Can't get new tag of $REPO/$IMAGE container --> existing"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2019-11-06 22:26:30 +01:00
|
|
|
DEFAULT=$(git branch|grep ^*|cut -c3-)
|
2019-11-30 14:32:49 +01:00
|
|
|
VERSION=${2:-$DEFAULT}
|
2019-11-06 22:26:30 +01:00
|
|
|
BRANCH=$(echo $VERSION|sed 's/\.[0-9]\{8\}$//')
|
|
|
|
[ $VERSION = $BRANCH ] && VERSION="$BRANCH.x-dev"
|
|
|
|
|
2020-01-02 19:49:02 +01:00
|
|
|
[ $BRANCH = "master" ] && {
|
|
|
|
VERSION=dev-master
|
|
|
|
}
|
2019-11-30 14:32:49 +01:00
|
|
|
echo -e "\nbuilding $REPO/$IMAGE:$TAG\n"
|
|
|
|
|
2019-11-06 22:26:30 +01:00
|
|
|
cd $(dirname $0)
|
|
|
|
|
2019-11-30 14:32:49 +01:00
|
|
|
docker pull $BASE
|
2023-01-16 23:17:11 +01:00
|
|
|
docker build --no-cache --build-arg "VERSION=$VERSION" --build-arg="PHP_VERSION=$PHP_VERSION" -t $REPO/$IMAGE:$TAG . && {
|
2019-11-30 14:32:49 +01:00
|
|
|
docker push $REPO/$IMAGE:$TAG
|
|
|
|
|
2022-05-11 08:46:53 +02:00
|
|
|
# tag master by major PHP version eg. 8.1
|
|
|
|
[ $BRANCH = "master" ] && {
|
|
|
|
docker tag $REPO/$IMAGE:$TAG $REPO/$IMAGE:$PHP_VERSION
|
|
|
|
docker push $REPO/$IMAGE:$PHP_VERSION
|
|
|
|
}
|
2019-11-30 14:32:49 +01:00
|
|
|
|
|
|
|
# tag only recommended PHP version as latest and $BRANCH (eg. master)
|
2022-05-11 08:46:53 +02:00
|
|
|
[ $PHP_VERSION = $RECOMMENDED_PHP_VERSION ] && {
|
|
|
|
[ $BRANCH = "master" ] && {
|
|
|
|
docker tag $REPO/$IMAGE:$TAG $REPO/$IMAGE:latest
|
|
|
|
docker push $REPO/$IMAGE:latest
|
|
|
|
}
|
2019-11-30 14:32:49 +01:00
|
|
|
docker tag $REPO/$IMAGE:$TAG $REPO/$IMAGE:$BRANCH
|
2020-01-02 19:49:02 +01:00
|
|
|
docker push $REPO/$IMAGE:$BRANCH
|
2019-11-06 22:26:30 +01:00
|
|
|
}
|
2023-11-12 07:51:56 +01:00
|
|
|
}
|