Skip to content

Modernize Docker build infrastructure: multi-arch GitHub Actions + buildkit strategy - #222

Open
b23prodtm with Copilot wants to merge 4 commits into
fix/composefrom
copilot/update-docker-build-infrastructure
Open

b23prodtm with Copilot wants to merge 4 commits into
fix/composefrom
copilot/update-docker-build-infrastructure

Conversation

Copilot AI commented Jul 11, 2026 •

Copy link
Copy Markdown

Replaces the outdated single-arch CircleCI + GitHub Actions setup with the proven multi-platform buildkit strategy from balena-photo-cropper. Adds full armhf/aarch64/x86_64 matrix builds, GHA layer caching, buildkit secret mounts, and manifest merging.

CI/CD

  • New .github/workflows/docker-build.yml — replaces build.yml; uses docker/bake-action@v5, full 3-arch matrix, separated "Write buildkit secrets" step, GHA cache injection, manifest merge in deploy job
  • Removed .circleci/config.yml and .github/workflows/build.yml
  • Explicit permissions: contents: read / actions: write on both jobs (least-privilege)

docker-bake.hcl

  • Added REGISTRY, REGISTRY_IMAGE, GITHUB_SHA variables
  • New common target inheriting GHA cache (type=gha) — all service targets inherit it
  • Per-arch groups armhf / aarch64 / x86_64, each building all 4 services with platform-suffixed tags (arm32v7, arm64v8, amd64) plus branch-safe and SHA tags
target "common" {
  cache-from = ["type=gha"]
  cache-to   = ["type=gha,mode=max"]
}

target "php-fpm-x86_64" {
  inherits   = ["php-fpm"]
  platforms  = ["linux/amd64"]
  dockerfile = "Dockerfile.x86_64"
  tags = [
    "${REGISTRY}/${REGISTRY_IMAGE}/php-fpm:amd64",
    BAKE_TAG != "" ? "…:${BAKE_TAG}-amd64" : "",
    GITHUB_SHA != "" ? "…:${GITHUB_SHA}-amd64" : ""
  ]
}

manifest-push.sh (new)

  • Sources common.env for BALENA_PROJECTS, parses REGISTRY/DOCKER_ORG from docker-bake.hcl
  • Merges per-arch images into a single multi-platform manifest; pushes latest on main/development

common.env

  • BALENA_PROJECTS updated from path-based entries to service names: ( php-fpm httpd mysqldb balena-storage )

Dockerfiles

  • PHP base image bumped 7.4.33-fpm-alpine3.16 → 8.3-fpm-alpine across all arch variants and template (PHP 8.1+ required for CakePHP 5)
  • Node build stage pinned to node:20-alpine (drops end-of-life alpine 3.16)

Copilot AI changed the title [WIP] Update Docker build infrastructure for multi-platform support Modernize Docker build infrastructure: multi-arch GitHub Actions + buildkit strategy Jul 11, 2026
Copilot AI requested a review from b23prodtm July 11, 2026 14:47
@b23prodtm
b23prodtm marked this pull request as ready for review July 19, 2026 15:55
@b23prodtm
b23prodtm requested a review from Copilot July 19, 2026 16:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Modernizes the container build/release pipeline by moving to a multi-architecture Docker Buildx Bake approach on GitHub Actions (with GHA caching and a manifest-merge deploy step), while updating the application’s container base images to support newer CakePHP/PHP requirements.

Changes:

  • Added a new multi-arch GitHub Actions workflow that builds/pushes per-arch images and then merges them into multi-platform manifests.
  • Refactored docker-bake.hcl to introduce a shared GHA cache target, registry variables, and per-arch groups/targets with arch-suffixed tags.
  • Updated Dockerfiles to use newer Node/PHP base images; removed the legacy CircleCI and older GitHub Actions workflow.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
.github/workflows/docker-build.yml New multi-arch Buildx Bake workflow + deploy manifest-merge job.
docker-bake.hcl Adds registry/SHA vars, shared cache target, and per-arch build groups/targets.
manifest-push.sh New script to merge per-arch tags into multi-platform manifests.
common.env Updates BALENA_PROJECTS to service-name list used by manifest merge loop.
Dockerfile.x86_64 Updates Node/PHP base images for amd64 build.
Dockerfile.aarch64 Updates Node/PHP base images for arm64 build.
Dockerfile.armhf Updates Node/PHP base images for arm/v7 build.
Dockerfile.template Updates Node/PHP base images in the template.
.github/workflows/build.yml Removed legacy workflow replaced by docker-build.yml.
.circleci/config.yml Removed legacy CircleCI pipeline replaced by GitHub Actions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +70 to +78
- name: Write buildkit secrets
run: |
mkdir -p .balena/secrets
echo "${{ secrets.MYSQL_ROOT_PASSWORD }}" > .balena/secrets/secret_mysql_root_password
echo "${{ secrets.MYSQL_USER }}" > .balena/secrets/secret_mysql_user
echo "${{ secrets.MYSQL_PASSWORD }}" > .balena/secrets/secret_mysql_password
echo "${{ secrets.MYSQL_DATABASE }}" > .balena/secrets/secret_mysql_database
echo "${{ secrets.MASTER_PASSWORD }}" > .balena/secrets/secret_master_password

Comment thread manifest-push.sh
@@ -0,0 +1,85 @@
#!/usr/bin/env bash
set -eu
Comment thread Dockerfile.x86_64
# BEGIN - Multi-stage Build
# Stage 1: Install NodeJS dependencies
FROM node:20-alpine3.16 AS node-build
FROM node:20-alpine AS node-build
Comment thread Dockerfile.template
# BEGIN - Multi-stage Build
# Stage 1: Install NodeJS dependencies
FROM node:20-alpine3.16 AS node-build
FROM node:20-alpine AS node-build
Comment thread Dockerfile.armhf
# BEGIN - Multi-stage Build
# Stage 1: Install NodeJS dependencies
FROM node:20-alpine3.16 AS node-build
FROM node:20-alpine AS node-build
Comment thread Dockerfile.aarch64
# BEGIN - Multi-stage Build
# Stage 1: Install NodeJS dependencies
FROM node:20-alpine3.16 AS node-build
FROM node:20-alpine AS node-build
Comment on lines +100 to +101
permissions:
contents: read

@b23prodtm b23prodtm left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker-bake.hcl needs renaming secret files to id=some_var, target=./balena/secrets/some_var_file

@b23prodtm

This comment has been minimized.

@b23prodtm

Copy link
Copy Markdown
Owner

@copilot use project example b23prodtm/abudgetmanager contents Dockerfile a docker/compose to fix code in the current project runtime so that it build up correctly up to the deployment, abudgetmanager a many similarities and is more recently treated with balena cloud services working cakephp setup. There are rules I've been working on as using the one click deploy button method. Just follow the file structure in the example project I mentioned above.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants