The client folder holds all the react-related code and is considered the frontend.
The root folder holds all the backend-related code, and within this, there is a public
folder containing the npm run build
of our react app (client).
All of this will be automated by a Dockerfile
Our main aim is to ensure everything is in a single machine, so we are better off with a single code base rather than splitting this individually. This will help in the maintenance and managing of dependencies.
Moreover, we are about containerizing our application, so a single codebase is mandatory to create our Dockerfile and create CI/CD pipelines.
Using this code base, we will create a multiple interlined Dockerfile. For example, react build folder and backend server in the same server but in numerous docker containers within a single dokku instance.
We install MongoDB as a separate dokku instance and link it with our other dokku instance, which contains the APIs and Frontend.
It is similar to how we usually start any react application; all you have to do is cd client
from the root directory and then npm start
From the root directory,
cd client
npm run build
cd ..
npm start