docker-immich icon indicating copy to clipboard operation
docker-immich copied to clipboard

Optimize docker build to split layers | Currently a single huge layer (~2GB) causes daily full-image downloads

Open Daniel-McLarty opened this issue 4 months ago • 3 comments

I’m using imagegenius/immich:cuda on UnRAID and every update downloads the entire image layer again (~2GB), even for minor version updates.

Problem:

  • The build seems to pack most or all files into one massive layer.
  • This breaks caching: any change invalidates the entire layer.
  • On UnRAID, every update means downloading the full payload.
  • The result: wasted bandwidth, slow deployments, and rapidly growing docker image size during container runtime.

Suggested Improvements:

  • Break the Dockerfile into logical layers (e.g., base OS, dependencies, build artifacts, application code).

This change would dramatically improve usability, especially for users on UnRAID or constrained environments. Thanks!

Daniel-McLarty avatar Aug 04 '25 02:08 Daniel-McLarty

imo not that big of a problem (technically not even a problem), just a 'nice to have'.

the cuda package could be put in a cuda baseimage as that's where the 2GB comes from

CI disregards any cached layers (iirc) and rebuilds all layers so even if cudnn was moved to a seperate layer in the Dockerfile it would not make a difference.

You are most welcome to test this out and open a PR here or for a new cuda baseimage branch, I don't really have time to test things out anymore.

hydazz avatar Aug 05 '25 09:08 hydazz

@hydazz So if I get this correct, that 2GB is because CUDA is in the same layer as the stuff that changes in Immich with each update? So I can just put that in its own image and we should be good? If so I will start working on that.

Daniel-McLarty avatar Aug 05 '25 15:08 Daniel-McLarty

that is the largest package by far in the cuda image, moving the installation of the package to the baseimage will mean that the pulled image will be the same size as the normal :latest bottom layer (as this uses the baseimage)

hydazz avatar Aug 06 '25 08:08 hydazz