build docker images: Alpine + 8.3 PHP-FPM + NGINX #2
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
name: 'build docker images: Alpine + 8.3 PHP-FPM + NGINX' | |
on: | |
#push: | |
# branches: | |
# - 'main' | |
# - 'master' | |
# paths: | |
# - 'alpine.fpm_nginx.slim.Dockerfile' | |
# - 'alpine.fpm_nginx.Dockerfile' | |
# - 'alpine.fpm_nginx.extended.Dockerfile' | |
# - '.github/workflows/build_docker_images-php8_3-alpine_fpm_nginx.yaml' | |
workflow_dispatch: | |
schedule: | |
- cron: '45 5 23 * *' # At 05:45 on day-of-month 23. | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Shell-Script | |
id: script | |
run: | | |
BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
BUILD_DATE_NUMERIC="${BUILD_DATE//[^[:digit:]]/}" | |
COMMIT_HASH=${GITHUB_SHA::8} | |
GITHUB_REPO=${GITHUB_REPOSITORY,,} | |
GITHUB_REPO_SHORT=${GITHUB_REPO#*/} | |
GITHUB_REPO_SHORT=${GITHUB_REPO_SHORT#"docker-"} | |
DOCKER_REPO=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPO_SHORT} | |
REDHAT_QUAY_REPO=${{ secrets.REDHAT_QUAY_USERNAME }}/${GITHUB_REPO_SHORT} | |
PHP_VERSION="8.3" | |
# Set output parameters to github action. | |
echo ::set-output name=build_date::${BUILD_DATE} | |
echo ::set-output name=build_date_numeric::${BUILD_DATE_NUMERIC} | |
echo ::set-output name=commit_hash::${COMMIT_HASH} | |
echo ::set-output name=github_repo::${GITHUB_REPO} | |
echo ::set-output name=docker_repo::${DOCKER_REPO} | |
echo ::set-output name=redhat_quay_repo::${REDHAT_QUAY_REPO} | |
echo ::set-output name=php_version::${PHP_VERSION} | |
- name: Set up QEMU | |
id: qemu | |
uses: docker/setup-qemu-action@v1 | |
with: | |
image: tonistiigi/binfmt:latest | |
platforms: all | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@master | |
#- name: Login to GitHub Container Registry | |
# uses: docker/login-action@v1 | |
# with: | |
# registry: ghcr.io | |
# username: ${{ github.repository_owner }} | |
# password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
#- name: Login to RED HAT Quay.io Container Registry | |
# uses: docker/login-action@v1 | |
# with: | |
# registry: quay.io | |
# username: ${{ secrets.REDHAT_QUAY_USERNAME }} | |
# password: ${{ secrets.REDHAT_QUAY_PASSWORD }} | |
- name: Build-slim | |
uses: docker/build-push-action@v2 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
context: . | |
file: ./alpine.fpm_nginx.slim.Dockerfile | |
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v6 | |
pull: true | |
push: true | |
build-args: | | |
BUILD_DATE=${{steps.script.outputs.build_date}} | |
VCS_REF=${{steps.script.outputs.commit_hash}} | |
PHP_VERSION=${{steps.script.outputs.php_version}} | |
tags: | | |
docker.io/${{steps.script.outputs.docker_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine-slim | |
# ghcr.io/${{steps.script.outputs.github_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine-slim-${{steps.script.outputs.build_date_numeric}}.${{steps.script.outputs.commit_hash}} | |
# ghcr.io/${{steps.script.outputs.github_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine-slim | |
# quay.io/${{steps.script.outputs.redhat_quay_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine-slim | |
- name: Build | |
uses: docker/build-push-action@v2 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
context: . | |
file: ./alpine.fpm_nginx.Dockerfile | |
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7 | |
pull: true | |
push: true | |
build-args: | | |
BUILD_DATE=${{steps.script.outputs.build_date}} | |
VCS_REF=${{steps.script.outputs.commit_hash}} | |
PHP_VERSION=${{steps.script.outputs.php_version}} | |
tags: | | |
docker.io/${{steps.script.outputs.docker_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine | |
# ghcr.io/${{steps.script.outputs.github_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine-${{steps.script.outputs.build_date_numeric}}.${{steps.script.outputs.commit_hash}} | |
# ghcr.io/${{steps.script.outputs.github_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine | |
# quay.io/${{steps.script.outputs.redhat_quay_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine | |
- name: Build-extended | |
uses: docker/build-push-action@v2 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
context: . | |
file: ./alpine.fpm_nginx.extended.Dockerfile | |
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7 | |
pull: true | |
push: true | |
build-args: | | |
BUILD_DATE=${{steps.script.outputs.build_date}} | |
VCS_REF=${{steps.script.outputs.commit_hash}} | |
PHP_VERSION=${{steps.script.outputs.php_version}} | |
tags: | | |
docker.io/${{steps.script.outputs.docker_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine-extended | |
# ghcr.io/${{steps.script.outputs.github_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine-extended-${{steps.script.outputs.build_date_numeric}}.${{steps.script.outputs.commit_hash}} | |
# ghcr.io/${{steps.script.outputs.github_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine-extended | |
# quay.io/${{steps.script.outputs.redhat_quay_repo}}:${{steps.script.outputs.php_version}}-fpm-nginx-alpine-extended | |
- name: Docker Hub Description | |
uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
repository: ${{steps.script.outputs.docker_repo}} | |
short-description: ${{ github.event.repository.description }} | |
readme-filepath: README.md |