loading...

re: Dockerized SailsJS/ReactJS/MongoDB/Redis/RabbitMQ/Nginx denvironment VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Thanks a lot for your article. Can you give me some instruction for production build Specially because react create a static files. Thanks
 

Hi, Nguyen. Thank you that you routed your question from GitHub to here :)

About production - yes, your React app would build static files, JS, HTML and CSS, right. So how I would do it?
Here's a guide that basically builds the react app and installs Nginx into the same container. So Nginx would serve the static files from the build results folder.
However - in my article I proposed a stack where Nginx is in a separate container and let it be that way, for fun :)
In this case I would probably create a new data volume called "common" and mount it to both containers - Nginx and web.

web:
    ...
    volumes:
        common:/var/app/current/public
nginx:
    ...
    volumes:
        common:/var/app/current/public

Add into web/Dockerfile:

...
RUN npm i
RUN npm run build
...

In Nginx conf I'd set the document root to /var/app/current/public

I haven't exactly tested it in production but it could work, in theory at least. Worth to try?

Please mind - right now I don't have a ReactJS app handy, I'm playing with Svelte. So the build folders etc may differ. But I hope you get the idea.

If this doesn't work then try with shared folder and mount it with bind option.

code of conduct - report abuse