Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve build.sh #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions build-ubuntu.sh

This file was deleted.

88 changes: 43 additions & 45 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,56 @@

set -e

# determine swoole version to build.
TASK=${1}
CHECK=${!#}

function check_or_push() {
TAG=${1}
if [[ ${CHECK} == "--check" ]]; then
local TAG=${1}
if [[ "${2}" == "--check" ]]; then
echo "Checking $TAG ..."
version=`docker run hyperf/hyperf:$TAG php -v`
echo $version | grep -Eo "PHP \d+\.\d+\.\d+"
swoole=`docker run hyperf/hyperf:$TAG php --ri swoole` && echo $swoole | grep -Eo "Version => \d+\.\d+\.\d+" || echo "No Swoole."
fi

if [[ ${CHECK} != "--check" ]]; then
echo "Publishing "$TAG" ..."
# Push origin image
docker run hyperf/hyperf:$TAG php -v | grep -Eo "PHP \d+\.\d+\.\d+"
docker run hyperf/hyperf:$TAG php --ri swoole | grep -Eo "Version => \d+\.\d+\.\d+" || echo "Not found Swoole."
else
echo "Publishing \"$TAG\" ..."
docker push hyperf/hyperf:${TAG}
fi

echo -e "\n"
}

# build base image
if [[ ${TASK} == "build" ]]; then
export PHP_VERSION=7.3 && export ALPINE_VERSION=3.10 && docker-compose build alpine-base
export PHP_VERSION=7.3 && export ALPINE_VERSION=3.11 && docker-compose build alpine-base

export PHP_VERSION=7.4 && export ALPINE_VERSION=3.10 && docker-compose build alpine-base
export PHP_VERSION=7.4 && export ALPINE_VERSION=3.11 && docker-compose build alpine-base
export PHP_VERSION=7.4 && export ALPINE_VERSION=3.12 && docker-compose build alpine-base
export PHP_VERSION=7.4 && export ALPINE_VERSION=3.13 && docker-compose build alpine-origin-base
export PHP_VERSION=7.4 && export ALPINE_VERSION=3.14 && docker-compose build alpine-origin-base
export PHP_VERSION=7.4 && export ALPINE_VERSION=3.15 && docker-compose build alpine-origin-base

export PHP_VERSION=8.0 && export ALPINE_VERSION=3.11 && docker-compose build alpine-base
export PHP_VERSION=8.0 && export ALPINE_VERSION=3.12 && docker-compose build alpine-base
export PHP_VERSION=8.0 && export ALPINE_VERSION=3.13 && docker-compose build alpine-origin-base
export PHP_VERSION=8.0 && export ALPINE_VERSION=3.14 && docker-compose build alpine-origin-base
export PHP_VERSION=8.0 && export ALPINE_VERSION=3.15 && docker-compose build alpine-origin-base
export PHP_VERSION=8.0 && export ALPINE_VERSION=3.16 && docker-compose build alpine-origin-base

export PHP_VERSION=8.1 && export ALPINE_VERSION=3.12 && docker-compose build alpine-base
export PHP_VERSION=8.1 && export ALPINE_VERSION=3.13 && docker-compose build alpine-base
export PHP_VERSION=8.1 && export ALPINE_VERSION=3.14 && docker-compose build alpine-base
export PHP_VERSION=8.1 && export ALPINE_VERSION=3.15 && docker-compose build alpine-base
export PHP_VERSION=8.1 && export ALPINE_VERSION=3.16 && docker-compose build alpine-origin-base
fi

if [[ ${TASK} == "publish" ]]; then
# Push base image
TAGS="7.3-alpine-v3.10-base 7.3-alpine-v3.11-base 7.4-alpine-v3.10-base 7.4-alpine-v3.11-base 7.4-alpine-v3.12-base 7.4-alpine-v3.13-base 7.4-alpine-v3.14-base 7.4-alpine-v3.15-base 8.0-alpine-v3.11-base 8.0-alpine-v3.12-base 8.0-alpine-v3.13-base 8.0-alpine-v3.14-base 8.0-alpine-v3.15-base 8.1-alpine-v3.12-base 8.1-alpine-v3.13-base 8.1-alpine-v3.14-base 8.1-alpine-v3.15-base"
for TAG in ${TAGS}; do
check_or_push $TAG
case ${1} in
base)
docker-compose build -f ubuntu.compose.yml --build-arg PHP_VERSION=7.4 --build-arg UBUNTU_VERSION=20.10 ubuntu-base
;;
cli)
docker-compose -f ubuntu.compose.yml build --build-arg PHP_VERSION=7.4 --build-arg UBUNTU_VERSION=20.10 --build-arg SWOOLE_VERSION=${2} ubuntu-cli
;;
build)
docker-compose build --build-arg PHP_VERSION=7.3 --build-arg ALPINE_VERSION=3.10 alpine-base
docker-compose build --build-arg PHP_VERSION=7.3 --build-arg ALPINE_VERSION=3.11 alpine-base

docker-compose build --build-arg PHP_VERSION=7.4 --build-arg ALPINE_VERSION=3.10 alpine-base
docker-compose build --build-arg PHP_VERSION=7.4 --build-arg ALPINE_VERSION=3.11 alpine-base
docker-compose build --build-arg PHP_VERSION=7.4 --build-arg ALPINE_VERSION=3.12 alpine-base
docker-compose build --build-arg PHP_VERSION=7.4 --build-arg ALPINE_VERSION=3.13 alpine-origin-base
docker-compose build --build-arg PHP_VERSION=7.4 --build-arg ALPINE_VERSION=3.14 alpine-origin-base
docker-compose build --build-arg PHP_VERSION=7.4 --build-arg ALPINE_VERSION=3.15 alpine-origin-base

docker-compose build --build-arg PHP_VERSION=8.0 --build-arg ALPINE_VERSION=3.11 alpine-base
docker-compose build --build-arg PHP_VERSION=8.0 --build-arg ALPINE_VERSION=3.12 alpine-base
docker-compose build --build-arg PHP_VERSION=8.0 --build-arg ALPINE_VERSION=3.13 alpine-origin-base
docker-compose build --build-arg PHP_VERSION=8.0 --build-arg ALPINE_VERSION=3.14 alpine-origin-base
docker-compose build --build-arg PHP_VERSION=8.0 --build-arg ALPINE_VERSION=3.15 alpine-origin-base
docker-compose build --build-arg PHP_VERSION=8.0 --build-arg ALPINE_VERSION=3.16 alpine-origin-base

docker-compose build --build-arg PHP_VERSION=8.1 --build-arg ALPINE_VERSION=3.12 alpine-base
docker-compose build --build-arg PHP_VERSION=8.1 --build-arg ALPINE_VERSION=3.13 alpine-base
docker-compose build --build-arg PHP_VERSION=8.1 --build-arg ALPINE_VERSION=3.14 alpine-base
docker-compose build --build-arg PHP_VERSION=8.1 --build-arg ALPINE_VERSION=3.15 alpine-base
docker-compose build --build-arg PHP_VERSION=8.1 --build-arg ALPINE_VERSION=3.16 alpine-origin-base
;;
publish)
TAGS=(7.3-alpine-v3.10-base 7.3-alpine-v3.11-base 7.4-alpine-v3.10-base 7.4-alpine-v3.11-base 7.4-alpine-v3.12-base 7.4-alpine-v3.13-base 7.4-alpine-v3.14-base 7.4-alpine-v3.15-base 8.0-alpine-v3.11-base 8.0-alpine-v3.12-base 8.0-alpine-v3.13-base 8.0-alpine-v3.14-base 8.0-alpine-v3.15-base 8.1-alpine-v3.12-base 8.1-alpine-v3.13-base 8.1-alpine-v3.14-base 8.1-alpine-v3.15-base)
for TAG in "${TAGS[@]}"; do
check_or_push "$TAG" $2
done
fi
;;
esac