Docker: NodeJS, ReactJS, MongoDB, MySQL

Kafka
Oct 18, 2020

I was working on a project that used nodeJS, ReactJS, MySQL and MongoDB. This project wasn’t using docker. So I decided to implement it and dockerize everything into separate containers. The reason to do this is to set up a standardize developer environment for the team. Clearly running the project on different OS’s you're going to have issues arise. Furthermore, theres a lot of wasted time in setting up the developer environment.

Docker compose to the rescue

With docker-compose.yml we can virtually have an entire dev environment setup with a single command: docker-compose up --build

Git clone the repo then git checkout

git clone https://github.com/ottokafka/docker_nodejs_mongodb.git
git checkout react_node_mongo_mysql

docker-compose.yml

Heres what my project directory looks like

Lets run docker compose

docker-compose up --build 

That will build your containers

Hopefully you will see React, NodeJS, MongDB and MySQL running in containers.

Now connect up VS Code to the react or NodeJS container and start coding

Just Click the Docker icon in Vs code and right click container to attach VS Code. If you don’t have the docker extension for VS Code I highly recommend it.

Docker VS Code extension

Like I always said work smart not hard.

That’s it guys. I hope you guys got something out of this article. If this article helped you go ahead and smash that clap button. Cheers 🍺

--

--

Kafka

“Genius” is 1% inspiration and 99% perspiration. Accordingly, a ‘genius’ is often merely a talented person who has done all of his homework — T.E.