IHTSDO / snowstorm

Scalable SNOMED CT Terminology Server using Elasticsearch
Other
203 stars 80 forks source link

ARM64 images missing in Docker Hub #365

Open metaruslan opened 2 years ago

metaruslan commented 2 years ago

Hi guys! https://hub.docker.com/r/snomedinternational/snowstorm/tags is missing ARM images. Having multi-arch builds is the recommended approach: https://docs.docker.com/desktop/mac/apple-silicon/ There are 2 use cases: 1) Running on m1 macs (I see you do support m1 macs given this issue https://github.com/IHTSDO/snowstorm/issues/344 is already fixed in the code). 2) Running on AWS Gravitron (ARM) instances.

Is there any plan to provide ARM images? Is there a workaround for now for how to create an ARM image on an m1 mac manually?

Thanks in advance!

kaicode commented 2 years ago

I spent a few hours trying to figure this out but just getting lost. Any help welcome. I get further using the io.fabric8/docker-maven-plugin rather than the spotify one in the pom but no success yet.

metaruslan commented 2 years ago

I'm not familiar with the snowstorm maven docker setup, but here is what docker docs say: https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/ https://github.com/docker/buildx#building-multi-platform-images I haven't done it myself, so I cannot say what's the best approach. The end result is having linux/arm64/v8 in the OS/ARCH column of tags, e.g. like this: https://hub.docker.com/_/elasticsearch?tab=tags

johngrimes commented 2 years ago

I think the best way to do this is to break free of your Dockerfile and use Jib!

It’s easiest if you use a base image that is already multi-arch. It looks like you are using openjdk, so that should be fine.

An example of a multi-arch Jib build is in the Pathling POM: https://github.com/aehrc/pathling/blob/main/fhir-server/pom.xml

martingall87 commented 1 year ago

@kaicode I'm not sure how far you got with this before you hit a stumbling block, however I've just got a docker image building on my M1 Mac using the io.fabric8/docker-maven-plugin, though I had to update the base docker image as the adoptopenjdk/openjdk11:alpine image only supported linux/amd64.

Looking at the status of the official adoptopenjdk images on dockerhub they seem to be deprecated in favour of eclipse-temurin. This only seems to officially support Alpine for amd64 still, however there are instructions on how to create a custom JRE using the eclipse-temurin build.

I'm hoping to push up a branch in a fork shortly if that would be useful?

kaicode commented 1 year ago

I like the sound of what @johngrimes mentioned but I have no expertise or capacity in this area at the moment. @martingall87 yes please share your work if you get something working.

martingall87 commented 1 year ago

I like the sound of what @johngrimes mentioned but I have no expertise or capacity in this area at the moment. @martingall87 yes please share your work if you get something working.

Hi @kaicode, I've had a look into using a multi-arch Jib build as @johngrimes suggested. It was fairly straight forward to setup with limited changes required. The changes I've made are available here:

I've tried to document the changes in docs/using-jib-to-build-containers.md and how to build images. I'm more than happy to have a discussion about it.

kaicode commented 1 year ago

@martingall87 your work looks great.

@rorydavidson can you see any issue with replacing the docker file with this jib technique? Looks like we can still publish to DockerHub (and many others) and enables building for the M chip Macs. If no issue I'll ask Martin to create a PR for this.

martingall87 commented 1 year ago

@martingall87 your work looks great.

@rorydavidson can you see any issue with replacing the docker file with this jib technique? Looks like we can still publish to DockerHub (and many others) and enables building for the M chip Macs. If no issue I'll ask Martin to create a PR for this.

Thanks @kaicode for your feedback. One of my drivers (apart from running on my M1 Mac!) was to be able to run Snowstorm in AWS Elastic Container Service using arm64 containers as these are cheaper than the amd64 ones