Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Hub: support arm64 builds #740

Open
shumvgolove opened this issue Apr 26, 2023 · 7 comments
Open

Docker Hub: support arm64 builds #740

shumvgolove opened this issue Apr 26, 2023 · 7 comments
Assignees

Comments

@shumvgolove
Copy link
Collaborator

Currently, Docker workflow supports building and pushing only amd64 images to Docker Hub, since compiling arm64 binaries with qemu/docker results in OOM, even on powerful machines with 32Gb RAM. Let's figure out the best way to support arm64.

Currently, proposed solutions:

  • Integrate with CircleCI workflow
    • Requires separate workflow, not compatible with GitHub actions.
    • Requires 3 CI jobs: two for creating amd64 and arm64 respectfully and one for combining this images into manifest.
      Source: Multi-Arch Build With Docker Buildx and CircleCi
    • Simplex Chat need to apply for free tier plan for Open Source projects.
  • Selfhost Github runner on aarch64 hardware.
    • Need to figure out where to host arm server.
    • Set up Github runner (pretty straightforward).
    • Adjust docker-image.yml
@samsapti
Copy link
Contributor

samsapti commented Apr 26, 2023

Just to add to this: CircleCI has native ARM support, which is why it's expected to work.

If the self-hosted GitHub Actions runner solution is chosen, you still need three CI jobs, just like with CircleCI, because the arm64 build needs to run on the self-hosted runner while the others run on the GitHub-hosted runners.

@shumvgolove
Copy link
Collaborator Author

shumvgolove commented Apr 26, 2023

you still need three CI jobs ... because the arm64 build needs to run on the self-hosted runner while the others run on the GitHub-hosted runners

So we can not specify something like...

jobs:
  build-and-push:
    name: Build and push Docker image
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - application: smp-server
            dockerfile: build.Dockerfile
          - os: [ubuntu-latest, self-hosted]
    ...

…to build all the images to one manifest on separate runners automagically?

@samsapti
Copy link
Contributor

samsapti commented Apr 26, 2023

Actually yes, you could do something like that. Then you would only need two jobs, one with a matrix to build the images, and one for making the manifest. You could also use some Bash magic to get the architecture for the image tags, like so:

...
jobs:
  build-and-push-images:
    name: Build and push Docker image
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, self-hosted]
        include:
          - application: smp-server
            dockerfile: build.Dockerfile
    runs-on: ${{ matrix.os }}
    steps:
...
      - name: Get machine architecture for image tags
        id: arch
        run: |
          if [ "$(uname -m)" = "x86_64" ]; then
              echo "tag=amd64" >> "$GITHUB_OUTPUT"
          elif [ "$(uname -m)" = "aarch64" ]; then
              echo "tag=arm64" >> "$GITHUB_OUTPUT"
          fi

      - name: Extract metadata for Docker image
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.application }}
          flavor: |
            latest=auto
            suffix=-${{ steps.arch.output.tag }},onlatest=true
          tags: |
            type=semver,pattern=v{{version}}
            type=semver,pattern=v{{major}}.{{minor}}
            type=semver,pattern=v{{major}}
...
  create-and-push-manifest:
    name: Create and push Docker manifest
    needs: build-and-push-images
...

@pm4rcin
Copy link

pm4rcin commented Sep 11, 2023

Hi, did you guys figure out how to build the server without OOM killing everything? I've tried building docker image on my machine with 16G RAM (8GB zram) and it killed all of my desktop processes.

@samip5
Copy link

samip5 commented Oct 1, 2023

You could potentially ask for sponsorship for aarch64 VM's from https://osuosl.org/services/aarch64/

@pm4rcin
Copy link

pm4rcin commented Oct 30, 2023

The good news is that arm runners are coming to Github. The bad news is that it will be available as private beta from January 2024 so probably another half a year or more from then to general availability.

@pm4rcin
Copy link

pm4rcin commented Jan 30, 2024

There's M1 runner available from today. I'm not sure how to integrate it fully to current workflow but if someone has an idea we could test and finally upload arm64 to DockerHub.

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

No branches or pull requests

4 participants