Dockerizing a React application with Nodejs Postgres and NginX | dev and prod | step by step

  Рет қаралды 74,476

Codeching

Codeching

Күн бұрын

Пікірлер: 73
@codeching
@codeching 8 ай бұрын
If you really liked this video, now you can say thank you with the 'super like' button as well, you can find it under my video! Thank you for watching this :)!
@Ray47nl
@Ray47nl Жыл бұрын
I really love your tutorial! I had some problems setting up the client. I am using react 18 and i had to change some things in App.js to make it work: import { BrowserRouter as Router, Routes, Route, Link } from 'react-router-dom'; And also:
@codeching
@codeching Жыл бұрын
Thank you that you shared it! It will be useful for others.
@vitaminez85
@vitaminez85 Ай бұрын
hi, thanks for the video 'd like to ask if there is a way of running both client side and server side in the same docker Container ? or it's mondatory the run them in seperate containers managed by doker compose ? thanks
@codeching
@codeching 6 күн бұрын
Hi, yes of course you can run a backend and a frontend in the same container but it's not recommended and Docker was not intended to do something like this. The performance optimization is optimal if you run them separately. However you can run both of them in the same container and you can expose their ports to the outside world if it's neccesary. Also you can use an inside nginx to put them on the same port under subpaths.
@AKASH-sw9bs
@AKASH-sw9bs Жыл бұрын
Your tutorial is good for those who already know docker and nginx but dont know how to glue all these things up in production. Good job. Carry on
@codeching
@codeching Жыл бұрын
Thanks! :)
@AlexanderPoznanski
@AlexanderPoznanski Ай бұрын
Thank you!
@tudor14
@tudor14 Жыл бұрын
Great tutorial so far. I have one question - why do we need the client/nginx/default.conf for production? Can we not just do this: COPY --from=development /usr/client/build /usr/share/nginx/html.
@codeching
@codeching Жыл бұрын
Thanks. It could work if you just overwrite the index.html there (and copy all the files) and you're ok with the basic nginx configuration. We're creating a new configuration here where you could set many things. I haven't tried just to overwrite the html but it could work however I think it's a better solution if you create an own nginx config too where you can set up things e.g. port in my case. Usually in normal prod we're using port 80 but here I set 3000 inside nginx config just for demo purpose.
@tudor14
@tudor14 Жыл бұрын
@@codeching Thanks for that. That does make sense. And I've finished the other video with K8s (which was fantastic by the way) and I have another question: Lets say we only want to expose the client route to /, and not expose the server under /api like we do in the ingress-controller. How would we achieve this?
@swagz6440
@swagz6440 Жыл бұрын
Is there different configuration doing this tutorial with vue.js because i followed up to this point and I am getting bad gateway. My backend is working but my frontend doesnt seem to expose the port 5173
@nitinmungilwar659
@nitinmungilwar659 24 күн бұрын
Great man really helps me ❤
@codeching
@codeching 22 күн бұрын
Thank you! :)
@jaylenpatterson611
@jaylenpatterson611 2 жыл бұрын
Hi, Great video and very informative! I'm having an issue when we run docker-compose up --build though. It loads the nginx page instead of my react app and I cant figure out why not?
@codeching
@codeching 2 жыл бұрын
The development one or prod? In prod we have 2 nginx config, one for routing and one for HTTP server, check both. Also check the Dockerfile of the client, does it build the React succesfully? But I guess it's something about nginx configurations.
@onewizzard
@onewizzard 7 ай бұрын
hmm...maybe you can change the speed on the KZbin menu control. if at .50, and still too fast. maybe it's a you issue because I watched this 2.00 and this video was fine.
@codeching
@codeching 7 ай бұрын
Hi, there is no speed problem here.
@ערןאוצפ
@ערןאוצפ Жыл бұрын
great tutorial, one thing i didn't understand was the point of the rewrite
@codeching
@codeching Жыл бұрын
Thanks, it's just a rewrite. So when we map the whole application to /api then it could be required if in your application you have route only e.g for '/cars'. When we call /api/cars, then it will call /cars on your application.
@luisjavier5224
@luisjavier5224 2 жыл бұрын
Oh man. you go too fast it's difficult to follow you
@codeching
@codeching 2 жыл бұрын
Thank you for watching! :) it's a video, maybe you can pause it any time.
@stockholmsyndromeself-trea7517
@stockholmsyndromeself-trea7517 2 жыл бұрын
@@codeching And I paused many times indeed. It's very informative I did learn a lot.
@onewizzard
@onewizzard 7 ай бұрын
hmm...maybe you can change the speed on the KZbin menu control. if at .50, and still too fast. maybe it's a you issue because I watched this 2.00 and this video was fine.
@AugustoMontagna
@AugustoMontagna 2 жыл бұрын
Thanks for the video! Great explanation. I feel Im missing something though. When you present the architecture, there is an nginx for routing, I dont see the production version. Is it the same as for local? regards
@codeching
@codeching 2 жыл бұрын
Yes, in prod we have 2 nginx config, one for routing and one for HTTP server to serve the HTTP content. I'm speaking about it from 27:16
@roopamchakrawarty682
@roopamchakrawarty682 3 жыл бұрын
Thank you..Very helpful Video....Can you make more videos like this.please
@codeching
@codeching 3 жыл бұрын
Thank you so much! I will do my best in the future too :)
@user-kw9cu
@user-kw9cu Жыл бұрын
excatly what i was looking for
@unzi876
@unzi876 Жыл бұрын
awesome explanation. thank you💯💯
@codeching
@codeching Жыл бұрын
Thanks! :)
@admondtamang4119
@admondtamang4119 2 жыл бұрын
Great content. can we also use pm2 with nginx or nginx will be enough for load balancing?
@codeching
@codeching 2 жыл бұрын
You can use anything that you want :)) But I think nginx could be enough. We are using it in real envs. Of course when we moved to Kubernetes environment, there is an Ingress loadbalancer there above it.
@ugurgunes95
@ugurgunes95 Жыл бұрын
Thanks for the video, I've learnt a lot. I hava a problem which is cors policy. When I tried to register from my front end I see The same origin policy error all the time. I've tried so many configuraitons but still the same. Any suggestion? Have a nica day!
@kag3670
@kag3670 3 жыл бұрын
Thank you for your tutorial, I have a question, I have cloned your project and trying to start it, I am using windows and my hot reload is not working, when I make changes and save it reflects inside the container, but no reload happens, not on the front nor on the server.
@codeching
@codeching 3 жыл бұрын
You're welcome! Yes, I updated the source code of docker compose file. I added CHOKIDAR_USEPOLLING environment variable with true value to the client. In case of React application (Created with CRA) it's the way to restart the application inside the container when we save the code in dev environment. However, the volume is also important, but it's already set up in this project. In case of node js it should be working because the Docker file set up start script "nodemon" already.
@lovers_valley
@lovers_valley Жыл бұрын
so efficient coding
@colbyberger1881
@colbyberger1881 10 ай бұрын
Under rated video. This was really helpful!
@codeching
@codeching 10 ай бұрын
Thanks 😊!
@hemanthshankar4520
@hemanthshankar4520 3 жыл бұрын
is there any way to achieve this without using docker-compose
@codeching
@codeching 3 жыл бұрын
Yes, there are many ways, but this is the good in docker compose, you can run everything together and it has numerous advantage.
@ganapathisubramanyamjayam
@ganapathisubramanyamjayam 3 жыл бұрын
Saved me
@codeching
@codeching 3 жыл бұрын
Good to hear :D
@nithinkamineni9392
@nithinkamineni9392 Жыл бұрын
in Nginx file you mentioned "proxy_pass client" "proxy_pass api;" but where are you actually mentioning the urls or ports like this? eg: server: container_name: nanomedicine_server restart: unless-stopped image: nanomedicine-server-image:1.0.0 build: context: nanomedicine-backend target: production dockerfile: Dockerfile ports: #outside:inside(container) - 8080:8080 networks: - shared-network depends_on: - postgres
@edisonraulbarreirozambrano4519
@edisonraulbarreirozambrano4519 Жыл бұрын
Great video, Sir. Thanks for all the shared info.
@codeching
@codeching Жыл бұрын
Thank you! :)
@dinamohsen9768
@dinamohsen9768 2 жыл бұрын
what if we we use webpack as http server for react?
@codeching
@codeching 2 жыл бұрын
The stack of the applications doesn't matter from the Docker aspect.
@rauldeandrade
@rauldeandrade 3 жыл бұрын
Great video. I really appreciate the content. Great job!
@codeching
@codeching 3 жыл бұрын
Thank you for your response!
@Zentamusic
@Zentamusic 2 жыл бұрын
Thank you so much. I was having some trouble configuring nginx proxy requests to the backend in a personal project of mine but looks like this tutorial clears it up. Thank you
@codeching
@codeching 2 жыл бұрын
Very good to hear if it helped for you :) You're welcome!
@Ramesh140789
@Ramesh140789 Жыл бұрын
I'm getting 404 from nginx ..if I reload the page
@tyeasir
@tyeasir 2 жыл бұрын
this was very helpful, thank you
@codeching
@codeching 2 жыл бұрын
You're welcome! :)
@cetinca
@cetinca 8 ай бұрын
On the playlist the order of the video 7 and video 8 could be changed. It will make more sense if Kubernetes is after docerizing the app.
@codeching
@codeching 8 ай бұрын
I tried to edit it but it's hard because I have multiple videos about these topics :) The order is not so important because the videos are mostly random and not all are built in top of the previous one. But I tried to order it a little bit now. Thank you for your response!
@cetinca
@cetinca 8 ай бұрын
@@codeching thank you.
@Play_Streams
@Play_Streams 2 жыл бұрын
Great videos, very well explained concepts.
@codeching
@codeching 2 жыл бұрын
Thank you so much!
@aruezechukwuebuka7868
@aruezechukwuebuka7868 Жыл бұрын
I tried this but whenever I run "npm start" for the client it compiles successfully but nothing shows on localhost:3000, please any idea what could be wrong?
@codeching
@codeching Жыл бұрын
It could be lot of things. E.g. wrong port mapping, wrong front-end (not running), wrong port for your front-end application, wrong nginx config etc. I can't help you in this in detail sry.
@ajaygangarde
@ajaygangarde 6 ай бұрын
can access front end:- localhost:3050/
@Lindaine
@Lindaine 3 жыл бұрын
Why don't we setup nginx for the api as well?
@codeching
@codeching 3 жыл бұрын
At 23:33 we set it up, or what do you mean?
@codeching
@codeching 3 жыл бұрын
If you are talking about the production stack, there in case of client we do that because we would like to serve a static html and we are using nginx as a HTTP server in that case. For node it doesn't required, because we are using node server. But in the global Nginx config we put our node application behind /api route.
@Lindaine
@Lindaine 3 жыл бұрын
@@codeching I see, thanks!
@Lindaine
@Lindaine 2 жыл бұрын
@@codeching How about sockjs-node in nginx? I don't understand why it is there
@codeching
@codeching 2 жыл бұрын
@@Lindaine It's used to make the web sockets connection be able to connect to dev server., This is the devserver proxy path if you would like to use it. The webpack sends the update messages through a socket to hot reload.
@bagabaya5956
@bagabaya5956 Жыл бұрын
Thx so much for your work!
@mohamedyoussef8835
@mohamedyoussef8835 Жыл бұрын
Awesome video +++++++++++ 🙂
@codeching
@codeching Жыл бұрын
Thank you! :)))
LIFEHACK😳 Rate our backpacks 1-10 😜🔥🎒
00:13
Diana Belitskay
Рет қаралды 3,9 МЛН
The intro to Docker I wish I had when I started
18:27
typecraft
Рет қаралды 120 М.
Docker | Towards serving React (Nginx) with Django API (gunicorn)
48:35
Setting up a production ready VPS is a lot easier than I thought.
29:50
Node.js is a serious thing now… (2023)
8:18
Code With Ryan
Рет қаралды 650 М.
I built the same app 10 times // Which JS Framework is best?
21:58
Fireship
Рет қаралды 2,5 МЛН
Как запустить проект? ASP.NET Core + React + NGINX + Docker Compose
20:03
Docker Tutorial (+ Node & Postgres setup)
40:37
Classsed
Рет қаралды 32 М.