How to create a container for a MERN stack app with SSR?

Hello guys,

I am pretty new to Docker (and SSR) but I always wanted to give it a try. Since I want to deploy an app to AWS EC2 I thought the time has come. Of course I could to that without Docker but I imagine it’s more efficient to put MongoDB, Redis and Node into a container.

All tutorials and boilerplates I found had one thing in common. They split server (Express) and client (React) and tread them as separated services. In my opinion that works if I develop an one page app that needs access to a backend api. But if I want to use server side rendering the server needs access to the react components. So in this case I have to put server and client in one single service, or am I wrong?

I would really appreciate if you could guide me to an appropriate docker structure.

Tools I use are:

  • Node
  • Express
  • React (SSR)
  • MongoDB
  • Redis
  • Webpack

Thanks!
Best

What do you mean by server side rendering? You should generate your files during build time if you can.