github-actionsarm64

How to install packages to the GitHub runner before the container is launched


I have built and tested a custom Debian Docker image on a local Ubuntu server (amd64), and it successfully built packages for both amd64 and arm64 architectures.

However, installing packages like qemu-user-static is required on the local server.

Here's an example code of the GitHub workflow:

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: customed/debian
   steps:
     - uses: actions/checkout@v2
     - name: build
       run: |
         build.sh xxxx

The workflow above failed to be built for the arm64 architecture. What I want to accomplish is installing packages like qemu-user-static on the GitHub runner server (the host server), which needs to be done before the container is launched. I tried some approaches but none of those works.


Solution

  • If you have GitHub Team or Enterprise license you can use GitHub Arm runners:

    github runner settings

    If you don't have you can run the workflow on the regular runner (without container:), install the qemu-user-static, build your custom debian and run it, somethings like this:

    jobs:
      build:
      runs-on: ubuntu-latest
      steps:
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      
      - uses: actions/checkout@v2
      
      - name: Run in container
        uses: docker/setup-buildx-action@v3
      
      - name: Build and run
        uses: docker/build-push-action@v5
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          load: true
          tags: customed/debian:latest
          
      - name: Execute build script
        run: |
          docker run --rm customed/debian:latest ./build.sh xxxx