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

Make Dockerfile compatible with ARM #84

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Make Dockerfile compatible with ARM #84

wants to merge 7 commits into from

Conversation

JoaoNogueira-xyz
Copy link

Docker image docker.io/rust:1-alpine was not compatible with ARM.
Using the base image docker.io/alpine and installing rust instead will allow the image to be build for both ARM and x86.

Tested and working on a Pi model 3B, running Raspbian GNU/Linux 9.13

Closes #73

@QuantumEntangledAndy
Copy link
Collaborator

Can I ask how you build this for arm within github actions without using a raspberry pi? Perhaps I'm missing something.

@QuantumEntangledAndy
Copy link
Collaborator

QuantumEntangledAndy commented Oct 16, 2020

I think youd need to also make the GitHub action part use qemu and xbuild too. Could you have a look at the changes I tried in #76 and add those to the docker.yml in GitHub actions. Your best way to test is to use GitHub actions in your own repo.

@QuantumEntangledAndy
Copy link
Collaborator

QuantumEntangledAndy commented Oct 16, 2020

Something like this

- name: Set up QEMU
  if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
  uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
  if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
  uses: docker/setup-buildx-action@v1
- name: Login to dockerhub
  if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
  uses: docker/login-action@v1
  with:
    username: ${{ steps.string_user.outputs.lowercase }}
    password: ${{ secrets.DOCKER_TOKEN }}
- name: Get tag name
  if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
  id: tags
  run: |
    branch="${GITHUB_REF#refs/heads/}"
    tags="${REPO_NAME}:${branch}"
    if [ "${branch}" == "master" ]; then
      tags="${tags},${REPO_NAME}:latest"
    fi
    echo "::set-output name=TAGS::${tags}"
  env:
    REPO_NAME: ${{ steps.string_repo.outputs.lowercase }}
- name: Push to Docker Hub Debian
  if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
  uses: docker/build-push-action@v2
  with:
    platforms: linux/arm/v7,linux/amd64
    push: true
    file: Dockerfile
    tags: ${{ steps.tags.outputs.TAGS }}

So that the build machine makes both images before publishing to dockerhub

@QuantumEntangledAndy
Copy link
Collaborator

I would be interested in seeing if the alpine also runs into the qemu issues I was having #76 with the cargo build step failing due to inode sizes

@JoaoNogueira-xyz
Copy link
Author

You are correct, I was missing the github actions' configs and your suggestion seems to be working.

I created a docker hub repo to test it (https://hub.docker.com/r/joaonogueira114/neolink) and I am currently using that image on my raspberry pi and it is performing as expected.

@QuantumEntangledAndy
Copy link
Collaborator

Could you try with armv6 too. I had already gotten amd64/armv7/armv8 working. It was just armv6 for someone on a raspberry pi 1 that was causing me trouble.

@QuantumEntangledAndy
Copy link
Collaborator

I think I can see from your commit that you are trying to split armv6 out as its own build. When I tried something similar it overwrote the build on dockerhub rather than added to it. I'm sure there's a way to do it but I didn't look into it. Please tell me if you can manage this as I'd be interested.

Also are you breaking it out as its own build due to the build time? I found armv6 took over 7 hours. If we can get it to publish incrementally to docker hub maybe using a matrix would be more efficient than I seperate job.

@JoaoNogueira-xyz
Copy link
Author

Yes, that is what I was trying to do. When I bundled all builds together it timed out at 6h, however when I split them the times are:

  • arm v6: 2h
  • arm v7, v8 and amd64: 3h45m
    but the second build overwrote the first, as you reported.

I had never used github actions before so I am not sure yet what is causing this issues. But I will look into it in the next couple of days.

@QuantumEntangledAndy
Copy link
Collaborator

I think the overriding is part of docker rather than GitHub. I suspect that there is an option in docker to tell it to add to a published build but I haven't looked into it either yet.

@QuantumEntangledAndy
Copy link
Collaborator

This link seems to suggest that we build to different tags then crate a manifest that points to this different tags

@QuantumEntangledAndy
Copy link
Collaborator

Rather than making the manifest as described in that link we could go down the route of build on docker in GitHub job 1 and save the binary as an artifact. Then in job 2 cp in the binary to the docker and publish.

@QuantumEntangledAndy
Copy link
Collaborator

Personally though I think this is more effort then it is worth. Let's just leave it as amd64 and armv7 and add others at a later date.

@JoaoNogueira-xyz
Copy link
Author

I may take a final look during the weekend but ultimately I agree with you. Releasing it for amd64/armv7/armv8 will probably be enough for most users.

@QuantumEntangledAndy
Copy link
Collaborator

I've just noticed your docker-arm-v6.yaml the way this is setup won't it ovewrite the amd64/armhf/arm64 image on dockerhub when it gets pushed. I think perhaps we should remove that before merging this

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

Successfully merging this pull request may close these issues.

Raspberry Pi support for the docker image
2 participants