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 · 11 comments
Open

Docker Hub: support arm64 builds #740

shumvgolove opened this issue Apr 26, 2023 · 11 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.

@pm4rcin
Copy link

pm4rcin commented Jun 25, 2024

@epoberezkin could you try? It looks like they added it today https://github.blog/changelog/2024-06-24-github-actions-ubuntu-24-04-image-now-available-for-arm64-runners/

@tootbrute
Copy link

in the meantime, is there a way to setup our docker-compose files to build it ourselves?

@pm4rcin
Copy link

pm4rcin commented Aug 21, 2024

in the meantime, is there a way to setup our docker-compose files to build it ourselves?

I've built it many times in the past. If you have arm64 device then simply build it like described here https://github.com/simplex-chat/simplexmq?tab=readme-ov-file#using-docker-1. As for the compose you can just paste the docker run into some LLM and it will output the compose easily. I know because I've tried that on Perplexity.

@samip5
Copy link

samip5 commented Sep 4, 2024

https://github.blog/changelog/2024-09-03-github-actions-arm64-linux-and-windows-runners-are-now-generally-available/ It's generally available but only on Team and Enterprise plans :(

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

5 participants