Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the Docker multi-arch builds #390

Merged
merged 4 commits into from
Jan 24, 2025
Merged
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
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
Loading