Skip to content

PHP/FPM • Docker Build #18

PHP/FPM • Docker Build

PHP/FPM • Docker Build #18

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
---
name: "PHP/FPM • Docker Build"
on:
workflow_dispatch:
jobs:
build:
name: "Build php/fpm"
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
strategy:
matrix:
BASE_IMAGE_NAME: [ "ubuntu" ]
BASE_IMAGE_TAG: [ "jammy" ]
PHP_VERSION: [ "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3" ]
# ubuntu-jammy images are the default and will be built with and without '-ubuntu-jammy' suffix
include:
- BASE_IMAGE_NAME: ubuntu
BASE_IMAGE_TAG: jammy
DEFAULT_IMAGE: "true"
steps:
- uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: mirror.gcr.io/tonistiigi/binfmt:latest
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: image=moby/buildkit:master
config-inline: |
[registry."docker.io"]
mirrors = ["${{ secrets.DOCKER_PROXY }}"]
- uses: supplypike/setup-bin@v3
with:
uri: https://github.com/hairyhenderson/gomplate/releases/latest/download/gomplate_linux-amd64
name: gomplate
version: latest
- name: Generate Dockerfile
run: gomplate -f images/php/fpm/tpl.Dockerfile -o images/php/fpm/Dockerfile
env:
BASE_IMAGE_NAME: ${{ matrix.BASE_IMAGE_NAME }}
BASE_IMAGE_TAG: ${{ matrix.BASE_IMAGE_TAG }}
- name: Build and push default image
uses: docker/build-push-action@v5
if: ${{ matrix.DEFAULT_IMAGE == 'true' }}
with:
context: images/php/fpm/context
file: images/php/fpm/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
tags: |
${{ vars.DOCKER_REPO }}/php:${{ matrix.PHP_VERSION }}-fpm
${{ vars.DOCKER_REPO }}/php:${{ matrix.PHP_VERSION }}-fpm-${{ matrix.BASE_IMAGE_NAME }}-${{ matrix.BASE_IMAGE_TAG }}
build-args: |
PHP_VERSION=${{ matrix.PHP_VERSION }}
cache-from: type=registry,ref=${{ vars.DOCKER_REPO }}/php:${{ matrix.PHP_VERSION }}-fpm-${{ matrix.BASE_IMAGE_NAME }}-${{ matrix.BASE_IMAGE_TAG }}
cache-to: type=inline
- name: Build and push default image
uses: docker/build-push-action@v5
if: ${{ matrix.DEFAULT_IMAGE != 'true' }}
with:
context: images/php/fpm/context
file: images/php/fpm/Dockerfile
push: true
platforms: "linux/amd64,linux/arm64"
tags: |
${{ vars.DOCKER_REPO }}/php:${{ matrix.PHP_VERSION }}-fpm-${{ matrix.BASE_IMAGE_NAME }}-${{ matrix.BASE_IMAGE_TAG }}
build-args: |
PHP_VERSION=${{ matrix.PHP_VERSION }}
cache-from: type=registry,ref=${{ vars.DOCKER_REPO }}/php:${{ matrix.PHP_VERSION }}-fpm-${{ matrix.BASE_IMAGE_NAME }}-${{ matrix.BASE_IMAGE_TAG }}
cache-to: type=inline