https://github.com/vedant-mahajan/node-app-containerization
Containerize NodeJS app with MongoDB backend
https://github.com/vedant-mahajan/node-app-containerization
docker docker-compose nodejs
Last synced: 3 months ago
JSON representation
Containerize NodeJS app with MongoDB backend
- Host: GitHub
- URL: https://github.com/vedant-mahajan/node-app-containerization
- Owner: Vedant-MAHAjan
- Created: 2023-05-24T04:44:57.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-05-24T08:02:48.000Z (about 3 years ago)
- Last Synced: 2025-01-30T16:18:20.933Z (over 1 year ago)
- Topics: docker, docker-compose, nodejs
- Language: HTML
- Homepage:
- Size: 5.67 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 💻 Developing with Docker 🐳
This demo app shows a simple user profile app set up using
- index.html with pure js and css styles
- nodejs backend with express module
- mongodb for data storage
All components are docker-based
## With Docker
#### To start the application
Step 1: Create docker network
docker network create mongo-network
Step 2: start mongodb
docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=password --name mongodb --net mongo-network mongo
Step 3: start mongo-express
docker run -d -p 8081:8081 -e ME_CONFIG_MONGODB_ADMINUSERNAME=admin -e ME_CONFIG_MONGODB_ADMINPASSWORD=password --net mongo-network --name mongo-express -e ME_CONFIG_MONGODB_SERVER=mongodb mongo-express
_NOTE: creating docker-network in optional. You can start both containers in a default network. In this case, just emit `--net` flag in `docker run` command_
Step 4: open mongo-express from browser
http://localhost:8081
Step 5: create `user-account` _db_ and `users` _collection_ in mongo-express
Step 6: Start your nodejs application locally - go to `app` directory of project
npm install
node server.js
Step 7: Access you nodejs application UI from browser
http://localhost:3000
### With Docker Compose 📝
#### To start the application
Step 1: start mongodb and mongo-express
docker-compose -f docker-compose.yaml up
_You can access the mongo-express under localhost:8080 from your browser_
Step 2: in mongo-express UI - create a new database "my-db"
Step 3: in mongo-express UI - create a new collection "users" in the database "my-db"
Step 4: build a docker image from the application
docker build -t my-app:1.0 .
The dot "." at the end of the command denotes location of the Dockerfile.
Step 5: access the nodejs application from browser
http://localhost:3000
## Node Application
### Default profile

### Updated profile

## MongoDB Database
### Before updating the profile

### After updating the profile
* New Database created
* New Collection created
* Entry of the updated profile added

* Click on the "my-db" database
* Click on the "users" collection
* The updated profile data will be stored