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

Server: Adding ARM64 support for both ARM servers and macOS #9940

Closed

Conversation

peterwilli
Copy link

This allows to build on arm64 + amd64, I use (and tested) this image to run on my Odroid ARM server.

Test image is at: https://hub.docker.com/repository/docker/peterwilli/joplin-server/general (has both arm64 and amd64)

How to build an universal image: docker buildx build -f Dockerfile.server --tag=peterwilli/joplin-server --platform=linux/arm64,linux/amd64 --push

Ofcourse, replace peterwilli/joplin-server with your own tag.

Copy link
Contributor

github-actions bot commented Feb 14, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@peterwilli
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Feb 14, 2024
@laurent22
Copy link
Owner

Thanks but could you explain the commit? I don't understand how adding packages related to jpg, gif or svg has something to do with supporting an arm64 version?

@peterwilli
Copy link
Author

peterwilli commented Feb 15, 2024

Thanks but could you explain the commit? I don't understand how adding packages related to jpg, gif or svg has something to do with supporting an arm64 version?

For some reason, when not adding these, I get an error, I think it has to do with the canvas npm package. Let me rebuild without them so I can replicate it for you.

The docker build was done at commit d4b32d3a91008adbbde3cf26d293d8304742d07e: docker_build_error.log

@ifurther
Copy link

@laurent22 It will build canvas because it could not provide the arm version.

@laurent22
Copy link
Owner

Thanks for clarifying, that makes sense.

How to build an universal image: docker buildx build -f Dockerfile.server --tag=peterwilli/joplin-server --platform=linux/arm64,linux/amd64 --push

So does it mean if I change the command here, it will automatically create a universal image?

const dockerCommand = `docker build --progress=plain -t "${repository}:${imageVersion}" ${buildArgs} -f Dockerfile.server .`;

Or is there something more I would need to change?

@peterwilli
Copy link
Author

Or is there something more I would need to change?

You need Docker buildx command and if on X86, you need binfmt and the Qemu emulator: https://www.docker.com/blog/getting-started-with-docker-for-arm-on-linux/

I haven't checked your code if there's CI or anything, but if there is I'm likely able to add the right dependencies!

@laurent22
Copy link
Owner

If you could advise on what dependencies might be needed that would be great. We indeed build the Docker image on CI from an ubuntu-20.04 machine.

We then install these dependencies:

- name: Install Linux dependencies

And then run the above mentioned command:

const dockerCommand = `docker build --progress=plain -t "${repository}:${imageVersion}" ${buildArgs} -f Dockerfile.server .`;

Can you see something in there that would need to be changed?

@peterwilli
Copy link
Author

peterwilli commented Feb 16, 2024

Can you see something in there that would need to be changed?

I believe I do. Is there a way to verify this locally before I adjust my PR?

[Edit: typo]

@laurent22
Copy link
Owner

I believe I do. Is there a way to verify this locally before I adjust my PR?

Verifying this locally is hard, but you can add them to the PR and then it'll directly run on CI so we can check if all's good

@peterwilli
Copy link
Author

peterwilli commented Feb 16, 2024

I can try using act to run the actions locally (https://github.com/nektos/act), which always supported me well, I rather send it in correctly in 1 go 😆

laurent22 pushed a commit that referenced this pull request Feb 16, 2024
@ifurther
Copy link

@peterwilli docker publish the docker/setup-buildx-action@v3 action, it will support action use buildx. I suggest install package to one line.

@laurent22 Docker v23.0 use buildkit(buildx) to build container, dockerCommand should add --platform= for build different arch container.

@laurent22
Copy link
Owner

I can try using act to run the actions locally (https://github.com/nektos/act), which always supported me well, I rather send it in correctly in 1 go 😆

That sounds complex and it's definitely fine to use the PR CI for this purpose (I do it all the time!)

@laurent22
Copy link
Owner

I'm closing this for now as I'm trying to clear the PR backlog. I would be very keen to add support for ARM64 to the official Docker image though, so please let me know if you would like to continue looking into this and I'll reopen.

@laurent22 laurent22 closed this Mar 2, 2024
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.

3 participants