simplexmq icon indicating copy to clipboard operation
simplexmq copied to clipboard

Docker Hub: support arm64 builds

Open shumvgolove opened this issue 2 years ago • 11 comments

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

shumvgolove avatar Apr 26 '23 07:04 shumvgolove

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.

samsapti avatar Apr 26 '23 13:04 samsapti

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?

shumvgolove avatar Apr 26 '23 13:04 shumvgolove

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
...

samsapti avatar Apr 26 '23 15:04 samsapti

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.

pm4rcin avatar Sep 11 '23 16:09 pm4rcin

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

samip5 avatar Oct 01 '23 22:10 samip5

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 avatar Oct 30 '23 21:10 pm4rcin

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 avatar Jan 30 '24 21:01 pm4rcin

@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/

pm4rcin avatar Jun 25 '24 17:06 pm4rcin

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

tootbrute avatar Aug 21 '24 10:08 tootbrute

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.

pm4rcin avatar Aug 21 '24 17:08 pm4rcin

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 :(

samip5 avatar Sep 04 '24 15:09 samip5