Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node

ENV MONGO_DB_USERNAME=admin \
MONGO_DB_PWD=qwerty

WORKDIR /testapp

COPY . .

# 👇 This is what's missing
RUN npm install

CMD ["node", "server.js"]
19 changes: 19 additions & 0 deletions mongodb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3.8"

services:
mongo:
image: mongo
ports:
- "27017:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: qwerty

mongo-express:
image: mongo-express
ports:
- "8081:8081"
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: admin
ME_CONFIG_MONGODB_ADMINPASSWORD: qwerty
ME_CONFIG_MONGODB_URL: mongodb://admin:qwerty@mongo:27017/
5 changes: 4 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const express = require("express");

const app = express();
const path = require("path");
const MongoClient = require("mongodb").MongoClient;
Expand All @@ -7,11 +8,13 @@ const PORT = 5050;
app.use(express.urlencoded({ extended: true }));
app.use(express.static("public"));


const MONGO_URL = "mongodb://admin:qwerty@localhost:27017";

const client = new MongoClient(MONGO_URL);

//GET all users
app.get("/getUsers", async (req, res) => {
app.get("/getUsers" ,async (req, res) => {
await client.connect(URL);
console.log('Connected successfully to server');

Expand Down
19 changes: 19 additions & 0 deletions ubuntu@35.154.172.157/nodejs-apna-college/mongodb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3.8"

services:
mongo:
image:mongo
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME:admin
MONGO_INITDB_ROOT_PASSWORD:qwerty

mongo-express:
image:mongo-express
ports:
-8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME:admin
ME_CONFIG_MONGODB_ADMINPASSWORD:qwerty
ME_CONFIG_MONGODB_URL:mongodb://admin:qwerty@mongo:27017/