Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Push Multi-arch Image

on:
push:
branches:
- php*
workflow_dispatch:

jobs:
build-push:
name: Build and push multi-arch image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Extract base image tag from Dockerfile
id: extract-tag
run: |
# Extract FROM line and convert php:8.3-apache → php8.3-apache
BASE_IMAGE=$(grep -m1 '^FROM' Dockerfile | awk '{print $2}')
TAG=$(echo "$BASE_IMAGE" | tr ':' '-' | tr '/' '-')
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Extracted tag: $TAG"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository }}:${{ steps.extract-tag.outputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,23 @@ docker-compose stop

## Building the Docker image

The Docker image lives in [Docker Hub](https://hub.docker.com/repository/docker/localgovdrupal/apache-php). Ask in [Slack](https://localgovdrupal.slack.com/) if you need the permissions to push new images.
### Automated builds (GHCR)

Build with:
Multi-architecture images (amd64/arm64) are automatically built and pushed to GitHub Container Registry on every push to `php*` branches:

```
ghcr.io/<owner>/drupal-container:<php-version>-apache
```

For example: `ghcr.io/localgovdrupal/drupal-container:php-8.3-apache`

You can also trigger a build manually via the [Actions tab](../../actions/workflows/build-push.yml).

### Manual builds (Docker Hub)

The Docker image also lives in [Docker Hub](https://hub.docker.com/repository/docker/localgovdrupal/apache-php). Ask in [Slack](https://localgovdrupal.slack.com/) if you need the permissions to push new images.

Build and push manually with:

```bash
export branch=$(git symbolic-ref --short HEAD)
Expand Down