Skip to content

Build image

Build image #18

Workflow file for this run

name: Build image
on:
workflow_dispatch:
inputs:
php-run-id:
description: PHP workflow run ID
type: number
jobs:
build-and-push:
strategy:
matrix:
php: ['8.1', '8.2', '8.3', '8.4']
flavor: ['distroless', 'base']
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download PHP artifacts
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.inputs.php-run-id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
build-args: |
PHPVERSION=${{ matrix.php }}
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/opencodeco/distroless-php:${{ matrix.php }}${{ matrix.flavor == 'base' && '-base' || '' }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: ./${{ matrix.flavor }}.Dockerfile