build-image icon indicating copy to clipboard operation
build-image copied to clipboard

Create multiarch images and push them to the dockerhub

Open lukasholzer opened this issue 3 years ago • 4 comments

As in #818 we introduced the arm64 compatibility for the image now we need to create a multi arch image and push it:

we need to change our pipeline to run with buildx

As far as I've seen the regular docker orb does not provide a way for it. Basically we need to do this:

# use the buildx driver
docker buildx create --use

docker buildx build \
  --tag=docker.io/<< parameters.image-name >>:${SHA1_IMAGE_TAG} \
  --tag=docker.io/<< parameters.image-name >>:${BRANCH_IMAGE_TAG} \
  --build-arg NF_IMAGE_VERSION=${CIRCLE_SHA1} \
  --build-arg NF_IMAGE_TAG=${VERSION_TAG} \
  --target << parameters.build-target >> <<# parameters.squash >> --squash <</ parameters.squash >> \
  --platform linux/amd64,linux/arm64 \
  --push \
  .

This should then cross compile the image in parallel and build for both platforms once this is pushed.

CleanShot 2022-07-15 at 12 57 47@2x

This is the prerequisite to get the buildbot image working for Mac M1 arm64 as well.

lukasholzer avatar Jul 15 '22 10:07 lukasholzer

Currently hitting a wall with cross compilation issues and some of our binaries like wkhtml and erlang.

Currently questioning if it is worth the effort on trying to do so @kitop and digging more into the rabbit hole or waiting for jammy where we could drop support for a lot of binaries that are old (maybe they are not needed anymore)

Not sure if I find a way around that:

------
 > [7/7] RUN dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb:
#0 0.060 dpkg: error processing archive wkhtmltox_0.12.6-1.focal_amd64.deb (--install):
#0 0.060  package architecture (amd64) does not match system (arm64)
#0 0.070 Errors were encountered while processing:
#0 0.070  wkhtmltox_0.12.6-1.focal_amd64.deb
------

https://app.circleci.com/pipelines/github/netlify/build-image/591/workflows/6663b065-6ddf-47af-83eb-750713bedb23/jobs/1628?invite=true#step-106-4918

lukasholzer avatar Aug 09 '22 14:08 lukasholzer

Mhmm... would love to have a full list of the dependencies and evaluate based on that. But current hunch is that we might better wait if this is not being a big blocker (ie: we have a workaround) at the moment. What do you think?

kitop avatar Aug 09 '22 18:08 kitop

So the full list would be:

  • homebrew (not working on arm in the current image as well, excluded via an if)
  • wkhtmltopdf (which throws this weird architecture issues)
  • Pandoc (which throws this weird architecture issues)

Seems like the issue is on the side of the packages: https://github.com/mavlink/MAVSDK/issues/1673 (different package but same issue)

So why we need the multi arch image is to run our buildbot tests inside this image and make local dev better working with it.

As The buildbot image extends from this one we would need a arm image to build on m1 macs.

lukasholzer avatar Aug 11 '22 09:08 lukasholzer

@kitop I've created a test image without them and pushed it so here it is: https://hub.docker.com/r/lukasholzer/build-image/tags

It's the build image excluding the 2 things from the top: CleanShot 2022-08-11 at 11 46 01@2x

lukasholzer avatar Aug 11 '22 09:08 lukasholzer

Current status (Pipeline for building the image on circleci is working and already pushing it to hub.docker.com)

netlfiy/build:chore-build-multiarch-image

CleanShot 2022-08-18 at 11 33 37

CleanShot 2022-08-18 at 13 11 42

Need to run the structure tests for arm64 as well as I noticed that we are blocked by our binrc library which does not support arm64 https://github.com/netlify/binrc/issues/36

lukasholzer avatar Aug 18 '22 09:08 lukasholzer