Skip to content

Build Image

Build Image #66

Workflow file for this run

name: Build Images
on:
workflow_call:
inputs:
php-version:
required: true
type: string
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
workflow_dispatch:
inputs:
php-version:
required: true
description: 'PHP version to build'
jobs:
build:
if: github.repository == 'nayleen/docker-php'
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
include:
- php: ${{ inputs.php-version }}
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-22.04' || 'ubuntu-22.04-arm' }} # nice segfaults, 24.04
steps:
- name: Check Out
uses: actions/checkout@v4
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Export PHP version to ENV
run: echo "PHP_VERSION=${{ matrix.php }}" >> $GITHUB_ENV
- name: Export Image Name to ENV
run: echo "IMAGE=${{ vars.REGISTRY }}/php:${{ matrix.php }}-${{ matrix.arch }}" >> $GITHUB_ENV
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Bake and Push Docker Images
uses: docker/bake-action@v6
env:
REGISTRY: ${{ vars.REGISTRY }}
with:
source: .
push: true
set: |
php.cache-from=type=registry,ref=${{ env.IMAGE }}-cache
php.cache-to=type=registry,ref=${{ env.IMAGE }}-cache,mode=max
php.tags=${{ env.IMAGE }}
combine-manifests:
needs: build
runs-on: ubuntu-22.04
steps:
- name: Check Out
uses: actions/checkout@v4
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Combine Manifests
run: |
docker buildx imagetools create -t ${{ vars.REGISTRY }}/php:${{ inputs.php-version }} \
${{ vars.REGISTRY }}/php:${{ inputs.php-version }}-amd64 \
${{ vars.REGISTRY }}/php:${{ inputs.php-version }}-arm64