Skip to content

Add optional docker_platforms input to control Docker build architecture(s) #156

@HDash

Description

@HDash

Summary

Add an optional input to specify the target platform(s) for the Docker image build, threaded through to the platforms: field of the docker/build-push-action@v6 step. The default would be empty, so the action omits platforms: entirely and builds for the runner's native architecture exactly as it does today — no behaviour change for existing users.

Motivation

Currently the Docker build (action.yml, the "🐳🚀 Build and Push to Docker Registry" step) sets no platforms: field, so every image is built only for the GitHub runner's native arch (linux/amd64). Users who want multi-arch images — e.g. linux/arm64 for Apple Silicon / ARM servers — have no way to request them without forking the action.

Proposed change

  1. New action input (action.yml), default empty:
    docker_platforms:
      description: >
        Comma-separated platforms to build the Docker image for, e.g.
        'linux/amd64,linux/arm64'. Leave empty (default) to build only for the
        runner's native architecture.
      default: ''
  2. Conditionally pass it to the build step (action.yml:704-721):
    platforms: ${{ inputs.docker_platforms }}
    An empty string here is treated by build-push-action as "no platforms set", so the default reproduces current behaviour.
  3. Thread the parameter through the R generators so it lands in user workflows:
    • R/use_workflow.R (add docker_platforms alongside the other docker_* args)
    • R/fill_yaml.R (add to the with2/arg list)
    • inst/templates/rworkflows_template.yml with: block
    • keep .github/workflows/rworkflows_static.yml in sync

Notes / caveats

  • Cross-building linux/arm64 on an amd64 runner requires docker/setup-qemu-action@v3 before the build step. We should add it (it's a no-op when only the native platform is built).
  • Multi-platform images can't be loaded into the local daemon, only pushed — fine here since the step already uses push: true.
  • cache-from/cache-to: type=gha remain compatible with multi-platform builds.

Backward compatibility

Fully backward compatible: empty default ⇒ no platforms: ⇒ identical to the current single-arch build.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions