We have developed one Magento2 Website Version - 2.2.1, in every instance - Production, Staging and Local facing the same issue as:
Error while running php bin/magento setup:di:compile
Repositories code generation breaks every time in 14% or 1/7 instance.
Repositories code generation... 1/7 [====>-----------------------] 14% < 1 sec 56.0 MiB