Multi-Architecture Image Builds using Packer and GitHub Self-Hosted Runners

Goals of this blog post:

Prerequisite Knowledge

Create Repository

Webhook

  • Ensure a GitHub webhook is configured to deliver workflow queued events to an AWS EventBridge Bus
    • a corresponding rule for the Event Bus should exist
    • the rule’s event pattern pattern should be configured to check for runner label prefix: debian-amd64
    • when an event matches the rule criteria, an ephemeral AMD64 self-hosted runner should run the workflow to build an ARM64 runner image
    • the workflow should also push the final image to ECR

Repository Variables/Secrets

Variables

ECR_REPOECR repository where ARM image will be uploaded to
RUNNER_PREFIXSelf-Hosted runner label prefix

Secrets

AWS_ACCOUNT_IDTarget AWS account 12 digit Identifier
AWS_REGIONAWS Region
OIDC_ROLEThe name of the OIDC IAM role which permits the workflow to perform scoped actions on target resources

Sample Build Output

Output from a sample workflow is shown below:

Build of the ARM-based image on AMD64 self-hosted runner progress:

Finally, the image is tagged and pushed to ECR: