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
58 changes: 0 additions & 58 deletions .github/workflows/main.yaml

This file was deleted.

32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# A simple MERN stack application

**Note** - To run this project using `docker compose`, follow the below steps.

Switch to the `compose` branch to learn the

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README reference to a 'compose' branch and instructions to "Switch to the compose branch to learn" appears incomplete. The sentence on line 5 ends abruptly without completing the thought. Either complete this sentence or remove the reference if the compose branch doesn't exist or isn't relevant.

Suggested change
Switch to the `compose` branch to learn the
Switch to the `compose` branch to learn the following Docker-based setup:

Copilot uses AI. Check for mistakes.

1. Implementation of `Dockerfile` for `client` and `server`.
2. Run the containers using `Docker Compose`.

Comment on lines +8 to +9

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README mentions running the project using 'docker compose' but doesn't provide the actual commands. Since the docker-compose.yaml file is now located in the mern/ directory, users need to know to run 'cd mern && docker compose up' or 'docker compose -f mern/docker-compose.yaml up' from the root directory. Consider adding these instructions to make the documentation complete.

Suggested change
2. Run the containers using `Docker Compose`.
2. Run the containers using `Docker Compose`. From the project root you can either:
- Change into the `mern` directory and run:
```bash
cd mern
docker compose up
```
- Or, from the project root, specify the compose file explicitly:
```bash
docker compose -f mern/docker-compose.yaml up
```

Copilot uses AI. Check for mistakes.
## Run it local without Docker

### Prerequisite

- Install `npm`

#### Start Server:

```
cd mern/server

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The directory path 'mern/server' is incorrect. The actual backend directory is 'mern/backend'. This should be updated to 'cd mern/backend' to match the actual project structure.

Suggested change
cd mern/server
cd mern/backend

Copilot uses AI. Check for mistakes.
npm install
npm start
```

#### Start Client

```
cd mern/client

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The directory path 'mern/client' is incorrect. The actual frontend directory is 'mern/frontend'. This should be updated to 'cd mern/frontend' to match the actual project structure.

Suggested change
cd mern/client
cd mern/frontend

Copilot uses AI. Check for mistakes.
npm install
npm run dev
```

<img width="1790" alt="Screenshot 2024-08-31 at 11 07 58 PM" src="https://github.com/user-attachments/assets/f414230b-8bd6-4393-b8de-6a10444a8dfd">
38 changes: 0 additions & 38 deletions docker-compose.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion mern/backend/db/connection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MongoClient, ServerApiVersion } from "mongodb";

const URI = "mongodb://mongodb:27017";
const URI = process.env.MONGODB_URI || "mongodb://mongo:27017";
const client = new MongoClient(URI, {
serverApi: {
version: ServerApiVersion.v1,
Expand Down
39 changes: 39 additions & 0 deletions mern/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
services:
frontend:
build: ./frontend
ports:
- "5173:5173"
networks:
- mern

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frontend environment is missing the backend API URL configuration. When running in Docker, the frontend container cannot reach the backend using 'http://localhost:5050' because each container has its own localhost. The old docker-compose.yaml had 'REACT_APP_API_URL: http://backend:5050' configured. You should either add this environment variable back or update the frontend code to use a configurable backend URL. For Vite, use 'VITE_API_URL' as the environment variable name.

Suggested change
- mern
- mern
environment:
- VITE_API_URL=http://backend:5050

Copilot uses AI. Check for mistakes.
backend:
build: ./backend
ports:
- "5050:5050"
networks:
- mern
environment:
- MONGODB_URI=mongodb://mongo:27017
depends_on:
mongo:
condition: service_healthy
mongo:
image: mongo:latest
ports:
- "27017:27017"
Comment on lines +21 to +22

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MongoDB service is exposing port 27017 to the host without authentication configured. This creates a security risk as anyone with network access can connect to the database. Consider either removing the port mapping (services within the same Docker network can communicate without exposing ports to the host) or adding authentication via environment variables like MONGO_INITDB_ROOT_USERNAME and MONGO_INITDB_ROOT_PASSWORD.

Suggested change
ports:
- "27017:27017"

Copilot uses AI. Check for mistakes.
networks:
- mern
volumes:
- mongo-data:/data/db
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.runCommand({ ping: 1 })"]

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The healthcheck uses 'mongosh' which is only available in MongoDB 5.0+. While 'mongo:latest' should include this, it would be more robust to add '--quiet' flag to suppress verbose output and use 'mongosh --quiet --eval' to make the healthcheck cleaner. Alternatively, for better compatibility with older MongoDB versions, consider using 'echo "db.runCommand({ ping: 1 })" | mongosh --quiet' or the legacy 'mongo' command.

Suggested change
test: ["CMD", "mongosh", "--eval", "db.runCommand({ ping: 1 })"]
test: ["CMD", "mongosh", "--quiet", "--eval", "db.runCommand({ ping: 1 })"]

Copilot uses AI. Check for mistakes.
interval: 10s
timeout: 5s
retries: 5

networks:
mern:
driver: bridge

volumes:
mongo-data:
driver: local
16 changes: 3 additions & 13 deletions mern/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
# Use the official image as a parent image
# Description: Dockerfile for the client side of the MERN stack application

# Use the official image as a parent image
FROM node:18.9.1

# Set the working directory
WORKDIR /app

# Copy the file from your host to your current location
COPY package.json .

# Run the command inside your image filesystem
RUN npm install

# Inform Docker that the container is listening on the specified port at runtime
EXPOSE 5173

# Copy the rest of your app's source code from your host to your image filesystem
COPY . .

# Run the specified command within the container
CMD ["npm", "run", "dev"]
EXPOSE 5173

CMD ["npm", "run", "dev"]
Loading