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

Multi-arch build #2

Merged
merged 14 commits into from
Oct 26, 2022
Merged

Multi-arch build #2

merged 14 commits into from
Oct 26, 2022

Conversation

schklom
Copy link
Contributor

@schklom schklom commented Oct 23, 2022

I enabled multi-arch builds, and daily PRs to update all GitHub Actions.

This will automatically create PRs to update the versions of the GitHub Actions e.g. `docker/login-action@v2` will update to `docker/login-action@v3` through a PR when available.
Standard way to build on multiple architectures with GitHub Actions.

I added amd64 (the default) and arm architectures. Feel free to change them if they don't work.
@oae
Copy link
Owner

oae commented Oct 23, 2022

Hi, Thank you for the pr. Can you change mangal's architecture in Dockerfile too? I would like to help but I don't have any arm device.

RUN curl -L https://github.com/metafates/mangal/releases/download/v3.12.0/mangal_3.12.0_Linux_x86_64.tar.gz -o mangal_3.12.0_Linux_x86_64.tar.gz && \
tar xf mangal_3.12.0_Linux_x86_64.tar.gz && \
mv mangal /usr/bin/mangal && \
chmod +x /usr/bin/mangal

@schklom
Copy link
Contributor Author

schklom commented Oct 23, 2022

mangal is only compiled for amd64, and the dev has a complete lack of instructions on building it from source (this is the first time I ever see a popular repo that lacks any build instructions).

I posted an issue asking about it (metafates/mangal#107), once the dev publishes build instructions, you will need to build mangal in your Dockerfile, then you can use it on other architectures.

In principle, I could run mangal on ARM using QEMU, but the performance would be very bad compared to a binary built for ARM.

@oae
Copy link
Owner

oae commented Oct 23, 2022

If you check the release page, it has several architectures.

@schklom
Copy link
Contributor Author

schklom commented Oct 23, 2022

I didn't see all the architectures on the release page, my bad, I was critical without having seen them :P

@schklom
Copy link
Contributor Author

schklom commented Oct 23, 2022

@oae I would add a few if conditions based on uname -m or uname -p to download the correct file.
For example

RUN if [ uname -m = "aarch64" ] \
    then \
    curl -L https://github.com/metafates/mangal/releases/download/v3.12.0/mangal_3.14.0_Linux_arm64.tar.gz -o mangal.tar.gz
    elif [ uname -m == "x86_64" ] \
    then \
    curl -L https://github.com/metafates/mangal/releases/download/v3.12.0/mangal_3.12.0_Linux_x86_64.tar.gz -o mangal.tar.gz
    elif [ uname -m == "armv6l" ] \
    then \
    curl -L https://github.com/metafates/mangal/releases/download/v3.12.0/mangal_3.14.0_Linux_armv6.tar.gz -o mangal.tar.gz
    elif [ uname -m == "i386" ] \
    then \
    curl -L https://github.com/metafates/mangal/releases/download/v3.12.0/mangal_3.14.0_Linux_i386.tar.gz -o mangal.tar.gz
RUN tar xf mangal.tar.gz
RUN mv mangal /usr/bin/mangal
RUN chmod +x /usr/bin/mangal 

I have not tested that the 4 uname -m are correct, but I think they are.

If you want to support more Linux architectures, you will need to build the binary in your Dockerfile. The dev added instructions, and I can help there.

Build mangal in a new `FROM golang` layer to support more architectures, or use if statements based on `uname -m` to decide which file to download like I did.
Copy link
Contributor Author

@schklom schklom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miswrote the version numbers

@schklom
Copy link
Contributor Author

schklom commented Oct 23, 2022

I added a few changes to support multiple architectures more easily.
Let me know if the build Action fails.

@oae
Copy link
Owner

oae commented Oct 24, 2022

the base image I use from linuxserver does not have all the platforms you specified. It only has arm64 and x86_64

@oae
Copy link
Owner

oae commented Oct 24, 2022

I also added a build job to pull requests so we can test if images are built successfully.

@schklom
Copy link
Contributor Author

schklom commented Oct 24, 2022

I changed the architectures to only x86_64 (amd64) and arm64

@oae
Copy link
Owner

oae commented Oct 25, 2022

I wonder if we can speed up the build. This takes too long and fails at the end because of timeouts.

@schklom
Copy link
Contributor Author

schklom commented Oct 26, 2022

I am not knowledgeable in Typescript and Lua, I can't help much there :/

However, if you need a faster Action to see if the Docker images build without error, I can help a little.
You can divide the build time by approximately 2 by temporarily disabling one of the architectures (x86_64 or arm64).

For example, you can adjust your GitHub Action temporarily like below

      - name: Build
        uses: docker/build-push-action@v3
        with:
          context: .
          file: docker/Dockerfile
          push: false
          # Possible architectures
          #platforms: linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6
---       platforms: linux/amd64,linux/arm64
+++       platforms: linux/arm64

@oae oae merged commit 9da4606 into oae:main Oct 26, 2022
@schklom
Copy link
Contributor Author

schklom commented Dec 10, 2022

@oae I know it is late, but I just thought that if you run into timeouts again later, you can split the Action in 2 separate Action files: one for amd64 and another for arm64. I think the timeout limit would be applied separately to each architecture instead of both.

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.

2 participants