inventree / InvenTree

Open Source Inventory Management System
https://docs.inventree.org
MIT License
4.15k stars 752 forks source link

[Docker] Image takes ages to build #6618

Open SchrodingersGat opened 7 months ago

SchrodingersGat commented 7 months ago

Edit: Docker push is not broken, but it does take a significant amount of time just to build this one package

image

After much research, this seems to be related specifically to building the alpine image on ARM.

The downloads page shows lots of other precompiled wheel options but not the ones we want.

References

Potential Solutions

A) Use pre-build grpcio library

Alpine ships the py3-grpcio package which comes with the 1.54.2 version of the library pre-installed. This may sidestep our need to build the library entirely.

B) Different Base Image

Alpine / musl is a big part of the "problem" here - using a different base image would make this a much more tractable problem.

C) Compile Wheel

Can we compile a wheel for grpcio ourselves for the aarch64 architecture?

D) Consider Default Support for grpcio

Currently we use this for tracing. I do not want to split up dependencies, this is not my ideal solution. But including it here as a point of consideration.

SchrodingersGat commented 7 months ago

@matmair @wolflu05 this single library (grpcio) is the cause for our very long docker build times on GitHub Actions.

matmair commented 7 months ago

This was the main reason I implemented the matrix build as it seems there are problems with that solution I think c) would be the next best

wolflu05 commented 7 months ago

I think for a optimal setup, we need to:

  1. use matrix builds and merge the manifest so that we don't have the issue we recently had. See https://docs.docker.com/build/ci/github-actions/multi-platform/
  2. build our own wheel and cache that
  3. use the free m1 runners for arm building
matmair commented 7 months ago

regarding 3. - I tried to get docker running on mac and it seems to be difficult. To get the M1 runner we should run MacOS 14 which seems to have problems with colima.

Also see https://github.com/actions/runner-images/issues/17

matmair commented 7 months ago

Arm runners + docker seems to be a problem https://github.com/douglascamata/setup-docker-macos-action?tab=readme-ov-file#arm64-processors-m1-m2-m3-series-used-on-macos-14-images-are-unsupported; which kind of defeats the purpose

SchrodingersGat commented 7 months ago

I think compiling and caching our own wheel would go most of the way and certainly be a drastic improvement to our build times. That should be our priority

SchrodingersGat commented 7 months ago

Anyone have experience doing something like this in GitHub?

wolflu05 commented 7 months ago

Ok, thanks for referencing these. I now understand the trouble you mean. Very said that there are no Linux arm runners for free available.

matmair commented 7 months ago

I think compiling and caching our own wheel would go most of the way and certainly be a drastic improvement to our build times. That should be our priority

Looking into it. Seems simpler than getting docker to run

matmair commented 7 months ago

Maybe we can use piwheels too - they are already building wheels https://www.piwheels.org/project/grpcio/

SchrodingersGat commented 7 months ago

@matmair isn't that for armv7 only?