Based on the logs the issue is memory usage. See the following support guide.
You mentioned that though it builds locally, it does it slowly so it seems the site is very resources intensive. If you are unable to reduce the resources required, you may need to look at the High Performance Build environment (I don’t work for Netlify, I’m not trying to sell, simply a suggestion.)