Skip to content

Add multi-arch Docker build workflow (amd64, arm64, armv7)#710

Open
guidoffm wants to merge 2 commits into
volkszaehler:masterfrom
guidoffm:upstream-docker-multiarch
Open

Add multi-arch Docker build workflow (amd64, arm64, armv7)#710
guidoffm wants to merge 2 commits into
volkszaehler:masterfrom
guidoffm:upstream-docker-multiarch

Conversation

@guidoffm

@guidoffm guidoffm commented Jun 6, 2026

Copy link
Copy Markdown

Summary

Add a GitHub Actions workflow that builds the existing Dockerfile for the three architectures vzlogger is most commonly deployed on, and publishes the resulting image to GHCR.

  • Platforms: linux/amd64, linux/arm64, linux/arm/v7 — covers regular x86_64 hosts, modern Raspberry Pi 4/5, and the still-popular 32-bit Pi 2B/3.
  • Cross-builds non-host architectures on the ubuntu-latest runner via QEMU + Buildx.
  • Pushes to ghcr.io/${{ github.repository }} only on master pushes and v*.*.* tags — PRs build but do not push (security-by-default).
  • Image is signed with cosign via the runner's GitHub OIDC identity (no long-lived secret required).
  • GitHub Actions cache (type=gha) makes incremental rebuilds fast.
  • workflow_dispatch is included so maintainers can trigger an ad-hoc rebuild without waiting for the daily cron.

All action pins use floating major versions that are Node.js 24 compatible (Node 20 actions are forced off after 2026-09-16).

Validation

Verified end-to-end on my fork: same workflow file built amd64 + arm64 + armv7 green in ~5min with cache hits, and published a signed multi-arch manifest to ghcr.io/guidoffm/vzlogger. PR with the green run: guidoffm#1

Notes for maintainers

  • The workflow uses IMAGE_NAME: ${{ github.repository }} → publishes to ghcr.io/volkszaehler/vzlogger. If you'd prefer a different registry path (e.g. Docker Hub volkszaehler/vzlogger), only the REGISTRY / IMAGE_NAME env vars and the login secrets need changing.
  • The daily schedule: cron (26 23 * * *) was carried over from the GitHub starter template — happy to drop it if you'd rather rebuild only on changes.
  • Cosign signing currently signs with a public-good Rekor transparency log, which is the right default for a public image; remove the final step if undesired.

Test plan

  • PR triggers Docker workflow via the pull_request event
  • All three platforms build green
  • After merge, first master run pushes the image to ghcr.io/volkszaehler/vzlogger:master and signs it

guidoffm added a commit to guidoffm/vzlogger that referenced this pull request Jun 6, 2026
Add a GitHub Actions workflow that builds the Dockerfile for
linux/amd64, linux/arm64 and linux/arm/v7 and publishes the
resulting signed image to ghcr.io/guidoffm/vzlogger on master
pushes and v*.*.* tags. PRs build but do not push.

QEMU + Buildx cross-build non-host architectures on the amd64
runner; GHA cache speeds incremental rebuilds; workflow_dispatch
allows ad-hoc rebuilds. All action pins are Node.js 24 compatible.

Also opened against upstream as volkszaehler#710.
guidoffm added 2 commits June 6, 2026 16:05
Build the existing Dockerfile for linux/amd64, linux/arm64 and
linux/arm/v7 - covering the platforms vzlogger is most commonly
deployed on - and publish the resulting image to GHCR.

Triggers and tag policy:
- `push` of a v*.*.* tag is the only event that publishes to the
  registry. Pull requests build the image (so changes that break
  the Dockerfile fail CI) but do not push, and `workflow_dispatch`
  on a non-tag ref also builds without publishing.
- `metadata-action` is configured explicitly so a release tag
  produces :{{version}}, :{{major}}.{{minor}} and :latest, with
  :latest tied to the highest release tag (not to whatever master
  happens to be). `flavor: latest=false` suppresses the default
  auto-`latest`-on-default-branch behaviour.

Other choices:
- QEMU + Buildx are used to cross-build non-host architectures
  on the amd64 runner.
- The image is signed with cosign via the GitHub OIDC identity -
  no long-lived secret required.
- GitHub Actions cache (type=gha) speeds incremental rebuilds.

Action pins use the current major versions, all of which support
Node.js 24 (GitHub forces Node 24 from 2026-06-16 and removes
Node 20 entirely on 2026-09-16).
Companion to the new docker-build workflow:

- Add compose.yaml as the canonical run-from-image example,
  mounting only vzlogger.conf instead of overlaying /etc, with
  a clear placeholder for the meter's /dev/serial/by-id path
  and an opt-in port mapping for the local HTTP API.
- Rewrite the README's Docker section to lead with the prebuilt
  multi-arch image (ghcr.io/volkszaehler/vzlogger:latest, signed
  with cosign) and `docker compose up`, keeping the local build
  path documented for development. The previous remark that
  `docker build` would pull source from upstream was incorrect -
  the Dockerfile copies the local checkout - and has been
  dropped.
@guidoffm guidoffm force-pushed the upstream-docker-multiarch branch from f6a2d55 to 31343f9 Compare June 6, 2026 14:05
Comment thread compose.yaml
devices:
# Replace with the persistent path of your meter's USB serial
# adapter. You can pass multiple device entries if needed.
- /dev/serial/by-id/usb-FTDI_FT230X_Basic_UART_XXXXXXXX-if00-port0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we maybe rather encourage to use variables for this than hardcode it?
https://docs.docker.com/compose/how-tos/environment-variables/set-environment-variables/

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The compose file is only an example and replaced the docker read command, but it is easier to read. Of course someone can introduce environment variables.

@r00t-

r00t- commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

the github workflow definition file looks like it's largely boilerplate code copied from somewhere
(the PR description even mentions "GitHub starter template"),

can you include a pointer to where it's taken from,
or ideally check in a copy and then a commit with the local changes?
that would make this much more practical to review.

@guidoffm

Copy link
Copy Markdown
Author

the github workflow definition file looks like it's largely boilerplate code copied from somewhere (the PR description even mentions "GitHub starter template"),

can you include a pointer to where it's taken from, or ideally check in a copy and then a commit with the local changes? that would make this much more practical to review.

It is AI generated. No need to re-invent. Before AI I used to copy the file from a blueprint project. The most important thing is that the build is multi platform and the image could be executed everywhere.

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.

2 participants