RUN npm run build takes forever

I’m running on MacOS with Docker Desktop.
I have a Dockerfile and it has a “RUN npm run build” command that takes forever (I ran for 30 mins and gave up). The same command locally (“npm run build” just takes 2 minutes).
Any idea what is going on?
I have enough resources allocated - 16GB and 12 cores.

How about you share your Dockerfile?

package.json might help, too.

Here is the full context -
And docker file is here:

Thank you

Any suggestions on how to debug and fix?

Where does it hang? How about you share the command line output?

On this line (RUN npm run build) -
it runs and never finishes. I tried until like 1200 seconds and gave up. On local it just takes a few seconds.

Why do you build, when there is a vectara/vectara-answer image available?

Well, the local machine is macOS and the container is Linux. If you have a new Mac with an arm cpu, then you are emulating an amd64 architecture. Emulation is not perfect.

So the issue could be emulation, but I also remember when someone tried to build an application which worked on Linux but not on MacOS because of some missing dependencies. Even though in most of the cases the build should run on all machines the same way, it is not always the case when the build depends on the CPU or the kernel. Although in that case I would expect some error messages about missing dependencies so when it just runs forever, I would say it is because the build is running on an emulated CPU.

I see - thank you. To confirm I think I can just try it on an EC2 normal machine and see if it’s different right?

If you can try a Mac instance which is not arm, that would only prove that it could work on another machine and with Docker Desktop on Mac. Not that the problem was the emulation, but it would be still likely. Although then you would run nested virtual machine and I don’t know how that affect performance Hopefully it would be just a little slower but could finish. I also don’t know how nested virtualization should be enabled on EC2.

Thanks for the suggestions. I just upgraded to Docker Desktop 4.26.1 and now it runs without any issues. I think the recent fixes to Rosetta probably helped