Skip to content

Commit

Permalink
Merge pull request #390 from Roave/add-multi-arch-builds-to-ci-run
Browse files Browse the repository at this point in the history
Fix the Docker multi-arch builds
  • Loading branch information
asgrim authored Jan 24, 2025
2 parents 7f7edca + 5d8226c commit 08e8e62
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
40 changes: 26 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,38 @@ jobs:
name: Build CI container
runs-on: ubuntu-latest
steps:
- name: "Install BuildX"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
with:
install: true

- name: "Build docker image"
uses: "docker/build-push-action@v6"
- name: Build docker image
uses: docker/build-push-action@v6
with:
target: "development"
tags: "ghcr.io/roave/docbooktool:test-image"
push: "false"
load: "true"
cache-from: "type=gha,scope=ci-cache"
cache-to: "type=gha,mode=max,scope=ci-cache"
target: development
tags: ghcr.io/roave/docbooktool:test-image
push: false
load: true
cache-from: type=gha,scope=ci-cache
cache-to: type=gha,mode=max,scope=ci-cache

- name: "Psalm"
run: "docker run --rm --entrypoint=php ghcr.io/roave/docbooktool:test-image vendor/bin/psalm"
- name: Psalm
run: docker run --rm --entrypoint=php ghcr.io/roave/docbooktool:test-image vendor/bin/psalm

- name: "PHPUnit"
run: "docker run --rm --entrypoint=php ghcr.io/roave/docbooktool:test-image vendor/bin/phpunit"
- name: PHPUnit
run: docker run --rm --entrypoint=php ghcr.io/roave/docbooktool:test-image vendor/bin/phpunit

- name: "PHPCS"
run: "docker run --rm --entrypoint=php ghcr.io/roave/docbooktool:test-image vendor/bin/phpcs"
run: docker run --rm --entrypoint=php ghcr.io/roave/docbooktool:test-image vendor/bin/phpcs

- name: Build docker image (multi-arch validation)
uses: docker/build-push-action@v6
with:
target: production
tags: ghcr.io/roave/docbooktool:test-image
platforms: linux/amd64,linux/arm64
cache-from: type=gha,scope=ci-cache
cache-to: type=gha,mode=max,scope=ci-cache
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

FROM composer:2.8.5 AS composer-base-image
FROM node:23.4.0 AS npm-base-image
FROM ubuntu:24.04 AS ubuntu-base-image
FROM ubuntu:22.04 AS ubuntu-base-image

FROM npm-base-image AS npm-dependencies

Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: *
.PHONY: help build build-tested test cs static-analysis test-output production validate-multiarch

CLEAR_CONFIG_CACHE=rm -f storage/app/vars/*
OPTS=
Expand Down Expand Up @@ -27,4 +27,13 @@ test-output: ## Write the test fixture outputs to build/ directory - useful for
docker buildx build --output=build --target=test-output --tag=ghcr.io/roave/docbooktool:test-image .

production: ## Build and tag a production image
docker buildx build --load --target=production --tag=ghcr.io/roave/docbooktool:latest .
docker buildx build --load --target=production --tag=ghcr.io/roave/docbooktool:latest .

.builder-name:
docker buildx create --use > .builder-name

validate-multiarch: .builder-name ## Validate the production build, multi-arch
docker buildx ls
docker buildx build --platform linux/amd64,linux/arm64 --target production --tag ghcr.io/roave/docbooktool:test-image .
docker buildx rm `cat < .builder-name`
rm .builder-name

0 comments on commit 08e8e62

Please sign in to comment.