Introduction
In today's fast-paced software development environment, containerization has become a popular and effective way to package ...
For further actions, you may consider blocking this person and/or reporting abuse
This is a really nicely explained article David :) Take my Unicorn 🦄
I would have loved a guide like this a few years ago, when I was Dockerizing my first application!
One final step that could be good to also mention (but maybe a bit out of scope) is distributing images on a registry like DockerHub / GHCR. Either through the UI, via CLI or using something like GitHub Actions to build, tag and publish images to registries, ready for direct consumption by users.
Thank you so much, Alicia. I'm glad you found the article helpful!
And you're absolutely right about the importance of distributing images on a registry like DockerHub or GHCR. That step is definitely worth mentioning, and I appreciate you bringing it up. It can be a bit overwhelming at first, but it's an essential part of the process, especially for teams working on collaborative projects.
Thanks again for reading and commenting on my article. I appreciate your feedback!
After docker compose up
I checked in postman with mentioned json payload.\
It is NOT working
Did we miss any step?
Even localhost8080 also not working and postman send error as :
`
Error
`
The URL is not correct, it should be: localhost:8080/api/register
But you had mentioned in your blog:
"To test the endpoints, send a POST request to register endpoint: localhost:8080/api/auth/register with the following JSON payload."
Did your MongoDB connection establish successfully?
Also, check if you missed any steps.
yes:
console.log is
node-with-docker-app-1 | MongoDB connected
Also I checkout github repo [github.com/davydocsurg/docker-node...] and try docker compose up from this repo.
same error.
Can you provide a screenshot of the error?
Sure...
your post url is incorrect. you can either change it to : localhost:8080/api/register
or
change your routes/auth.js routes to:
/auth/login and
/auth/register
@baljitweb Have a look at your setup as well
Nice content easy to understand the code line by line it's especially for beginners
This is really amazing and straight forward, I had issues with containerizing my docker to Nodejs, but this your article helped me resolve it. I would also recommend a typescript version
Thank you @wilsonibekason. I'm glad you found this helpful.
Really great article! This was a nice refresher for me as I'm getting back into web development after a break.
My only thought was that your demonstration doesn't highlight a multi-stage build. You speak to the benefits of why we'd write a multi-stage build, but you'd need to use multiple images for it to be multi-stage.
In this example, the first stage builds the application using the official Node.js image, and the second stage copies only the built files to a smaller Node.js Alpine image. The --from=build option in the COPY instruction tells Docker to copy files from the first stage of the build.
Well, I was looking for ways to optimize build of my app in the cloud, and you said that making the build multi-stage helps with that, but in your example did everything in just one stage. No examples on how one could use the FROM directive.
I would check the dockerfile, you use multi-stage builds but only use one stage so you are not using the benefits of multi-stage caching images builds