Sync from khs1994-docker/lnmp@c5e428598238eb4ff0640c0fa87cee5a846837f… #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
workflow_dispatch: | |
inputs: | |
PHP_VERSION: | |
description: php version | |
required: true | |
default: "8.1.31" | |
name: PHP_TOOL | |
env: | |
PHP_CUSTOM_VERSION: ${{ github.event.inputs.PHP_VERSION }} | |
defaults: | |
run: | |
shell: bash --noprofile --norc -exo pipefail {0} | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@main | |
with: | |
fetch-depth: 2 | |
- run: | | |
env | |
docker --version | |
docker compose version | |
name: 'manifest' | |
- run: | | |
echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USERNAME} --password-stdin | |
# echo ${DOCKER_PASSWORD} | docker login -u ${TENCENT_DOCKER_USERNAME} --password-stdin uswccr.ccs.tencentyun.com | |
echo ${DOCKER_PASSWORD} | docker login -u ${ALIYUN_DOCKER_USERNAME} --password-stdin registry.us-east-1.aliyuncs.com | |
echo ${GHCR_IO_TOKEN} | docker login -u khs1994 --password-stdin ghcr.io | |
echo ${CODING_DOCKER_PASSWORD} | docker login -u khs1994-1601432822176 --password-stdin pcit-docker.pkg.coding.net | |
name: 'Docker Login' | |
env: | |
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} | |
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} | |
TENCENT_DOCKER_USERNAME: ${{secrets.TENCENT_DOCKER_USERNAME}} | |
ALIYUN_DOCKER_USERNAME: ${{secrets.ALIYUN_DOCKER_USERNAME}} | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
GHCR_IO_TOKEN: ${{secrets.GHCR_IO_TOKEN}} | |
CODING_DOCKER_PASSWORD: ${{secrets.CODING_DOCKER_PASSWORD}} | |
- uses: docker-practice/actions-setup-docker@master | |
with: | |
docker_channel: test | |
docker_version: "20.10" | |
- run: | | |
docker --version | |
docker compose version | |
docker buildx version | |
docker | |
name: 'install-after-manifest' | |
- run: | | |
echo | |
cp .env.example .env | |
if [ -n "${PHP_CUSTOM_VERSION}" ];then | |
export PHP_TAG_VERSION=$PHP_CUSTOM_VERSION | |
fi | |
echo $GITHUB_REF | grep -q 'refs/tags/' && IS_TAG_EVENT=1 || true | |
if ! [ -n "${IS_TAG_EVENT}" -o "${GITHUB_EVENT_NAME}" = 'workflow_dispatch' ];then \ | |
export PLATFORM=linux/amd64; \ | |
if [ "$PHP_VERSION" = 8_X_X -o "$PHP_VERSION" = nightly ];then \ | |
export PLATFORM=linux/amd64,linux/arm64,linux/arm/v7; \ | |
IS_PUSH=--push; \ | |
mirror="${add_mirror}"; \ | |
else \ | |
IS_PUSH=--push; \ | |
DOCKER_HUB_USERNAME=$DOCKER_HUB_USERNAME_TEST; \ | |
fi; \ | |
else \ | |
IS_PUSH=--push \ | |
&& mirror="${add_mirror}"; \ | |
fi | |
VCS_REF=`git rev-parse --short HEAD` | |
CACHE_IMAGE=ghcr.io/${DOCKER_HUB_USERNAME}/php | |
# CACHE_IMAGE=${DOCKER_HUB_USERNAME}/php | |
echo "::group::Build php-cs-fixer" | |
docker buildx build \ | |
-t $DOCKER_HUB_USERNAME/php:php-cs-fixer \ | |
$(for item in `echo $mirror`;do echo " -t ${item}:php-cs-fixer ";done) \ | |
--build-arg USERNAME=$DOCKER_HUB_USERNAME \ | |
--cache-from=$DOCKER_HUB_USERNAME/php:php-cs-fixer-cache \ | |
--cache-to=$DOCKER_HUB_USERNAME/php:php-cs-fixer-cache \ | |
--platform ${PLATFORM} ${IS_PUSH} php-cs-fixer | |
echo "::endgroup::" | |
echo "::group::Build doctum" | |
docker buildx build \ | |
-t $DOCKER_HUB_USERNAME/php:doctum \ | |
$(for item in `echo $mirror`;do echo " -t ${item}:doctum ";done) \ | |
--build-arg USERNAME=$DOCKER_HUB_USERNAME \ | |
--cache-from=$DOCKER_HUB_USERNAME/php:doctum-cache \ | |
--cache-to=$DOCKER_HUB_USERNAME/php:doctum-cache \ | |
--platform ${PLATFORM} ${IS_PUSH} doctum | |
echo "::endgroup::" | |
echo "::group::Build phpdox" | |
docker buildx build \ | |
-t $DOCKER_HUB_USERNAME/php:phpdox \ | |
$(for item in `echo $mirror`;do echo " -t ${item}:phpdox ";done) \ | |
--build-arg USERNAME=$DOCKER_HUB_USERNAME \ | |
--cache-from=$DOCKER_HUB_USERNAME/php:phpdox-cache \ | |
--cache-to=$DOCKER_HUB_USERNAME/php:phpdox-cache \ | |
--platform ${PLATFORM} ${IS_PUSH} phpdox | |
echo "::endgroup::" | |
echo "::group::Build phploc" | |
docker buildx build \ | |
-t $DOCKER_HUB_USERNAME/php:phploc \ | |
$(for item in `echo $mirror`;do echo " -t ${item}:phploc ";done) \ | |
--build-arg USERNAME=$DOCKER_HUB_USERNAME \ | |
--cache-from=$DOCKER_HUB_USERNAME/php:phploc-cache \ | |
--cache-to=$DOCKER_HUB_USERNAME/php:phploc-cache \ | |
--platform ${PLATFORM} ${IS_PUSH} phploc | |
echo "::endgroup::" | |
echo "::group::Build phpcpd" | |
docker buildx build \ | |
-t $DOCKER_HUB_USERNAME/php:phpcpd \ | |
$(for item in `echo $mirror`;do echo " -t ${item}:phpcpd ";done) \ | |
--build-arg USERNAME=$DOCKER_HUB_USERNAME \ | |
--cache-from=$DOCKER_HUB_USERNAME/php:phpcpd-cache \ | |
--cache-to=$DOCKER_HUB_USERNAME/php:phpcpd-cache \ | |
--platform ${PLATFORM} ${IS_PUSH} phpcpd | |
echo "::endgroup::" | |
echo "::group::Build phpmd" | |
docker buildx build \ | |
-t $DOCKER_HUB_USERNAME/php:phpmd \ | |
$(for item in `echo $mirror`;do echo " -t ${item}:phpmd ";done) \ | |
--build-arg USERNAME=$DOCKER_HUB_USERNAME \ | |
--cache-from=$DOCKER_HUB_USERNAME/php:phpmd-cache \ | |
--cache-to=$DOCKER_HUB_USERNAME/php:phpmd-cache \ | |
--platform ${PLATFORM} ${IS_PUSH} phpmd | |
echo "::endgroup::" | |
echo "::group::Build custom 7.0" | |
docker buildx build --push \ | |
--build-arg PHP_VERSION=7.0.33 \ | |
--build-arg USERNAME=khs1994 \ | |
-t ${DOCKER_HUB_USERNAME}/php:7.0-custom custom/7.0 | |
echo "::endgroup::" | |
echo "::group::Build custom 7.1 " | |
docker buildx build --push \ | |
--build-arg PHP_VERSION=${PHP_TAG_VERSION} \ | |
--build-arg USERNAME=${DOCKER_HUB_USERNAME} \ | |
-t ${DOCKER_HUB_USERNAME}/php:8.1-custom custom/7.1 | |
echo "::endgroup::" | |
echo "::group::Build full custom" | |
docker buildx build \ | |
--build-arg PHP_EXTENSION_EXTRA="xsl" \ | |
--build-arg PECL_EXTENSION_EXTRA="imagick msgpack" \ | |
--build-arg APK_EXTRA="libxslt imagemagick-libs libgomp musl" \ | |
--build-arg APK_DEV_EXTRA="libxslt-dev imagemagick-dev imagemagick" \ | |
--build-arg PHP_VERSION=${PHP_TAG_VERSION} \ | |
--build-arg USERNAME=${DOCKER_HUB_USERNAME} \ | |
--push \ | |
-t ${DOCKER_HUB_USERNAME}/php:8.1-full-custom 8.1/fpm | |
echo "::endgroup::" | |
env: | |
GITHUB_EVENT_NAME: ${{github.event_name}} | |
DOCKER_HUB_USERNAME: khs1994 | |
DOCKER_HUB_USERNAME_TEST: lrew | |
PLATFORM: linux/amd64,linux/arm64 #,linux/arm/v7 | |
PHP_VERSION: 8_1_X | |
FOLDER: "8.1" | |
PHP_TAG_VERSION: "8.1.31" | |
TYPE: ${{ matrix.TYPE }} | |
add_mirror: registry.us-east-1.aliyuncs.com/khs1994-us/php pcit-docker.pkg.coding.net/khs1994-docker/khs1994/php ghcr.io/khs1994/php | |
name: 'Build Image' |