diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml new file mode 100644 index 0000000..de0daeb --- /dev/null +++ b/.github/workflows/build-push.yml @@ -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 diff --git a/README.md b/README.md index 1df9d94..b8177ef 100644 --- a/README.md +++ b/README.md @@ -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//drupal-container:-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)