I had the same issue.
I found that I had to change the MAMP php.ini file directly, rather than the template.
When I ran
php -r "echo ini_get('memory_limit').PHP_EOL;” from within the root I wasn't seeing the memory limit that I changed in the MAMP template for the version of php I was using.
But when I went to Applications > MAMP > bin > php > [PHP VERSION] > conf > php.ini and edited the file there and ran
php -r "echo ini_get('memory_limit').PHP_EOL;” again I was seeing the correct value.
Once I did that compilation worked and I was able to get Production mode set.