✔️ Development of a basic APP using NodeJS, ExpressJS and JavaScript,
containerizing it through the use of Docker containers.
✔️ Creation of a Docker network where a MongoDB container and another one with MongoExpress
(MongoDB graphical interface) communicate with each other.
✔️ Adjustment of the configuration in MongoExpress to enhance the visualization and updating of data.
✔️ Using the Dockerfile, we manually simulate the Jenkins process to package and compile
the artifact of a new version of the APP into a Docker Image.
✔️ Using AWS CLI, the Image is deployed to a private repository in AWS ECR
(Elastic Container Registry).
✔️ By using Docker Compose, the Image is extracted from the private AWS repository,
thereby allowing accessibility to the development server and facilitating access to the APP.
Step 1: Create docker network
docker network create mongo-network
Step 2: start mongodb. Use your own environment variables.
docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME} -e MONGO_INITDB_ROOT_PASSWORD=${MONGO_INIT_ROOT_PASSWORD} --name mongodb --net mongo-network mongo
Step 3: start mongo-express. Use your own environment variables.
docker run -d -p 8081:8081 -e ME_CONFIG_MONGODB_ADMINUSERNAME=${ME_CONFIG_MONGODB_ADMINUSERNAME} -e ME_CONFIG_MONGODB_ADMINPASSWORD=${ME_CONFIG_MONGODB_ADMINPASSWORD} --net mongo-network --name mongo-express -e ME_CONFIG_MONGODB_SERVER=${ME_CONFIG_MONGODB_ADMINMONGODBSERVER} 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.cjs
Step 7: Access you NodeJS application UI from browser
http://localhost:3000
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: start node server
npm install
node server.cjs
Step 5: access the NodeJS application from browser
http://localhost:3000
docker build -t docker-project:1.0 .
NOTE: The dot "." at the end of the command denotes location of the Dockerfile.
If you want to contribute to this project, follow these steps:
-
Perform a fork to the repository.
-
Create a branch for your feature or bugfix:
git checkout -b feature/your-feature-name
-
Make the necessary changes and commits:
git commit -m 'Add some feature'
-
Push to branch:
git push origin feature/your-feature-name
-
Send a pull request to the original repository.
Kevin Schans |
---|