Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to run Dockerized React application in SSR (Server Side Rendering) mode

I have a React application which runs on Docker container and interacts with .NET Core application running on another container. I want to run my React application in SSR (Server Side Rendering) mode. How can I do it? Should I install Nextjs in React application container?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

For this you can build your docker image from nginx. first you have to build your react app. See the following
example dockerfile:

FROM nginx:alpine

# adding nginx.conf file to the right place
COPY ./.nginx/nginx.conf /etc/nginx/nginx.conf

#remove default html file
RUN rm -rf /usr/share/nginx/html/*

#Copy index.html to nginx/html dir (this is the first thing request by browser)
COPY --from=builder /react-ui/build /usr/share/nginx/html

EXPOSE 3000 80

ENTRYPOINT ["nginx", "-g", "daemon off;"] 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading