diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ff40ee..2199fec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 7dd8471..0be8579 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Makefile b/Makefile index 455191f..072512e 100644 --- a/Makefile +++ b/Makefile @@ -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= @@ -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