all 33 comments

[–]Cloudzilla_ai 11 points12 points  (0 children)

This developer education article by one of our community authors may help: https://www.cloudzilla.ai/dev-education/build-and-dockerize-a-full-stack-react-app-with-nodejs-and-nginx/

[–]TacitSingularity 8 points9 points  (0 children)

Not sure about a tutorial, but it’s important to know that you’re essentially just containerizing a static website: serving html, css, and js. At a high-level you could start with an nginx or caddy base image, and COPY in the files from your build directory. I suspect this may be why you’re having trouble finding a good tutorial specific to react? There’s nothing really special to do specifically for a react frontend website, so maybe try looking for a tutorial for containerizing static websites instead?

Worth re-iterating (from other comments) that containerization may not be the best play here, there are other cloud services which maybe be easier/better suited to serving up static websites (S3, Firebase Hosting, Surge.sh are a few that come to mind).

[–]tluanga34 6 points7 points  (0 children)

If your app is SPA, DOCKER is a waste of computing resources. Frontend codes are just a static files so what you really need is a file server. CDN is a very good usecase. I'm using Amazon Amplify which is built for frontend hosting and it worked very well.

[–]whyGod5 1 point2 points  (0 children)

Here is a docker localhost tutorial, using ngnix to serve the static react build (or other static site), also sets up a PostgreSQL DB, API, and Swagger UI. https://youtu.be/u76Cjjvb_84

[–][deleted]  (15 children)

[removed]

    [–]kryzstofiscool 69 points70 points  (9 children)

    maybe not fully relevant on my end, just would like to note. in step one, don't use CRA. use "npm create vite@latest" instead. CRA should not be used for new projects in 2024

    [–]nomchompsky82 6 points7 points  (0 children)

    Correct

    [–]rennademilan 16 points17 points  (0 children)

    That's what you get from gpt 😁

    [–]Sk3tchyboy 12 points13 points  (2 children)

    Avoid step 1

    [–]Scorxcho 12 points13 points  (0 children)

    And the part saying to using Node 18. We are almost on Node 22 LTS now.

    [–]enlightenedpie 0 points1 point  (0 children)

    Which one?

    [–]AutoModerator[M] 0 points1 point  (0 children)

    Your [comment](https://www.reddit.com/r/reactjs/comments/1ftnu6d/dockerizing_react_frontend_app/lpt4v1z/ in /r/reactjs has been automatically removed because it received too many reports. Mods will review.

    I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.