Ubuntu customization for headless mode

we plan customize the NVIDIA L4T ubuntu for a headless mode.
All un-required packages need remove from our customized image for safety and size reason.
May I know if there is a general guideline how to do that? For example to remove gnome, firefox etc.
thanks a lot

For L4T, rather ask in the Jetson forums, this one is x86
https://forums.developer.nvidia.com/c/agx-autonomous-machines/jetson-embedded-systems/70