Gatsby SSR docker image size is too large

Hi all, I am facing issue while deploying Gatsby SSR code to GCP using docker as an image container.
The image size is coming more than 3.0GB which is heavy for handling load and autoscaling in GCP.

Right now using single stage build in Docker
Where building the application first using Gatsby build and then serving it on a port using Gatsby serve command.

Because node modules are also part of the image so size is very high.

Tried nginx multi-stage build as well but that didn’t work because it is not able to find the index.html in the root of the build folder.

This is another issue index.html is not getting generated after running Gatsby build in my Gatsby SSR application

Please help me reduce the image size at most priority.

We cannot provide support with deploying to GCP or other platforms. These forums are for Netlify support.