Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Build multi-architecture container images on GitHub Actions

December 8, 2023
Ajay Pratap
Related topics:
Containers
Related products:
Red Hat Enterprise Linux

Share:

    Traditionally, container images were built and optimized for a specific architecture, such as x86 or ARM64. However, with the advent of diverse hardware architectures and the rise of cloud platforms, the need for multi-architecture support became crucial. Multi-architecture containers enable deploying the same image across different architectures seamlessly.

    Here's an example of a GitHub Actions workflow that builds multi-architecture container images for both amd64 and arm64 architectures when a pull request is created or when changes are pushed to the main branch:

    name: Build Multi-Architecture Container Image
    
    on:
      push:
        branches:
          - main
      pull_request:
        branches:
          - main
    
    jobs:
      build:
        runs-on: macos-latest
    
        steps:
        - name: Checkout repository
          uses: actions/checkout@v2
    
        - name: Set up QEMU
          uses: docker/setup-qemu-action@v1
    
        - name: Set up Docker Buildx
          uses: docker/setup-buildx-action@v1
    
        - name: Login to Docker registry
          uses: docker/login-action@v1
          with:
            username: ${{ secrets.DOCKER_USERNAME }}
            password: ${{ secrets.DOCKER_PASSWORD }}
    
        - name: Build and push multi-architecture image
          uses: docker/build-push-action@v5
          with:
            context: .
            push: true
            tags: |
              myregistry/myapp:latest-amd64
              myregistry/myapp:latest-arm64
            platforms: linux/amd64,linux/arm64
    

    In this example, the workflow is triggered when there is a push to the main branch or when a pull request is created or updated against the main branch. The workflow includes the following steps:

    1. Check out repository: This step checks out your repository's code.

    2. Set up QEMU: This step sets up QEMU for cross-building the arm64 architecture on amd64 host machines.

    3. Set up Docker Buildx: This step sets up Docker Buildx, a Docker command-line interface (CLI) plug-in for building multi-architecture images.

    4. Log in to the Docker registry: This step logs in to your Docker registry using the provided credentials stored as secrets in the repository settings.

    5. Build and push multi-architecture image: This step uses the docker/build-push-action to build and push the multi-architecture container image. The context parameter specifies the root directory of your Docker build context. The tags parameter specifies the tags for the generated images, including the architecture suffix (amd64 and arm64). The PLATFORMS environment variable specifies the target platforms for the build, which are linux/amd64 and linux/arm64.

    6. Make sure to replace myregistry with your Docker registry URL and provide the appropriate Docker registry credentials in the GitHub repository's secrets (DOCKER_USERNAME and DOCKER_PASSWORD).

    With this workflow in place, whenever there is a pull request or a push to the main branch, GitHub Actions will automatically build and push the multi-architecture container image for both amd64 and arm64 architectures. You can expand on this workflow by adding additional steps for testing, deploying, or other actions as per your project requirements.

    Here's an example of a GitHub Actions workflow that uses Podman to build multi-architecture container images for both AMD64 and ARM64 architectures on pull requests and the main branch:

    name: Build Multi-Architecture Container Image
    
    on:
      push:
        branches:
          - main
      pull_request:
        branches:
          - main
    
    jobs:
      build:
        runs-on: macos-latest
    
        container:
          image: myregistry/mypodman:latest
    
        steps:
          - name: Checkout repository
            uses: actions/checkout@v2
    
          - name: Log in to container registry
            run: echo "${{ secrets.CONTAINER_REGISTRY_PASSWORD }}" | podman login -u "${{ secrets.CONTAINER_REGISTRY_USERNAME }}" --password-stdin myregistry
    
          - name: Build and push multi-architecture image
            run: |
              podman build --format docker --platform linux/amd64,linux/arm64 -t myregistry/myapp:latest .
              podman push myregistry/myapp:latest
    

    In this example, the GitHub Actions workflow uses macos-latest, you can change it based on your requirement. The GitHub Actions workflow uses the custom Docker image containing Podman (mypodman:latest) to build and push the multi-architecture container image for both amd64 and arm64 architectures. The workflow will be triggered on every push to the main branch or when a pull request is created or updated against the main branch.

    Note that using Podman in GitHub Actions involves custom Docker images, and there might be limitations and compatibility considerations that you need to be aware of. Additionally, the example provided assumes you have set up secrets in your GitHub repository for your container registry credentials.

    Last updated: December 13, 2023

    Related Posts

    • What is Podman Desktop? A developer's introduction

    • Deploy and test Kubernetes containers using Podman Desktop

    • Managing Java containers with Quarkus and Podman Desktop

    • Working with Kubernetes in Podman Desktop

    • Containerize a Spring Boot application with Podman Desktop

    • How to transition from Docker to Podman

    Recent Posts

    • Create and enrich ServiceNow ITSM tickets with Ansible Automation Platform

    • Expand Model-as-a-Service for secure enterprise AI

    • OpenShift LACP bonding performance expectations

    • Build container images in CI/CD with Tekton and Buildpacks

    • How to deploy OpenShift AI & Service Mesh 3 on one cluster

    What’s up next?

    Podman is a daemonless container engine for developing, managing, and running Open Container Initiative (OCI) containers on Linux systems. Download the Podman Cheat Sheet and explore basic commands for managing images, containers, and container resources. 

    Get the cheat sheet
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue