Overcommit is irrelevant here, because the problem isn’t processes being OOM-killed prematurely, it’s just trying to stuff ten pounds of allocated memory into a five pound sack.
It’s not practically possible to run a Discourse rebuild with overcommit_memory=2, because ember (amongst other things, no doubt) pre-allocates masses of virtual memory (IIRC, 80GB or so is what I saw), so that’s always going to fall foul of any reasonable overcommit_ratio setting. Setting overcommit_memory=1 isn’t going to help, either, because, again, the problem isn’t an overzealous VMM killing processes, it’s hideously poor memory management from the ember compiler.