willhallonline / docker-ansible

Ansible inside Docker containers: Alpine, Ubuntu, Rocky & Debian with Ansible 2.16, 2.15, 2.14, 2.13, 2.12, 2.11, 2.10 and 2.9 + Mitogen
https://www.willhallonline.co.uk/project/docker/docker-ansible/
MIT License
397 stars 137 forks source link

ARM64v8 images #57

Closed spewu closed 1 year ago

spewu commented 2 years ago

Hi Will

I just got an M2 MacBook Air, and wanted to try running this container, but unfortunately discovered that it does not have any arm64v8 images. I see you use gitlab-ci, but I have never worked with that, so I am not sure which changes would be needed to include arm64v8 images as well - if you would be interested in that 😄

Would it be feasible to add ARM images as well?

https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/

Thanks!

spewu commented 2 years ago

OK, getting a local build running was pretty easy:

docker build --build-arg ARCH=arm64v8/ --build-arg ANSIBLE_CORE_VERSION_ARG=2.13.3 --build-arg ANSIBLE_VERSION=6.2.0 --build-arg ANSIBLE_LINT=6.4.0 ansible-core/alpine316/

but it would still be awesome if you could ship multi-arch builds 😄

willhallonline commented 2 years ago

If we were to do this I have a couple of questions. The change would probably just mean more inside the gitlab-ci.yml file.

  1. Should I run separate naming?
  2. Which architectures should we build? (Only arm64v8 or others?)
spewu commented 2 years ago

If we were to do this I have a couple of questions. The change would probably just mean more inside the gitlab-ci.yml file.

  1. Should I run separate naming?
  2. Which architectures should we build? (Only arm64v8 or others?)

So, first a caveat: I have not personally done this before, so my knowledge stems from my "theoretical" research, but this would be my answers to your questions:

  1. I don't think you should run separate naming. If you use docker buildx, then it will include all of the architectures in the same build, and with the same name. When a user then pulls the image, it will automatically pick the one that fits with their CPU architecture.
  2. I looked at some other popular images, and I see that a company like linuxserver, who builds and maintains a lot of docker images, seems to include these three: linux/amd64, linux/arm/v7 & linux/arm64/v8, e.g.: https://hub.docker.com/r/linuxserver/filezilla/tags
benmoss commented 2 years ago

Yep, with buildx you can create an "image index" (also known as a "manifest list").

Essentially a tag like alpine:latest will point to a list of images by OS and architecture, the client can use that and redirect itself to the appropriate one for the OS it's running on

An example, the ubuntu:latest image: https://explore.ggcr.dev/?image=ubuntu%3Alatest

willhallonline commented 2 years ago

OK. So my next fun update is that, yes, multi-arch builds work well... Unfortunately, they also take a long time, too long for my 60-minute CI process to complete (I guess due to having to having to emulate/simulate different architectures). I will see if I can find another way around it, or I might have to just run more CI jobs.

willhallonline commented 1 year ago

This is now working. I have already updated inside both Docker Hub and GitLab Registry. Also, I am working on an arm32 option which would mean that it would work in Raspberry Pi, but that is probably for a later release. Closing as I would say it is complete.

spewu commented 1 year ago

This is now working. I have already updated inside both Docker Hub and GitLab Registry. Also, I am working on an arm32 option which would mean that it would work in Raspberry Pi, but that is probably for a later release. Closing as I would say it is complete.

Nice - thanks 👏🏻