-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix MongoDB hostname + build contexts #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: compose
Are you sure you want to change the base?
Changes from all commits
dd393de
ba5abcf
bdc0e5c
05f9e82
c60ab8f
59b27e0
a1f1376
bb70f4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| 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 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| 1. Implementation of `Dockerfile` for `client` and `server`. | ||||||||||||||||||||||||||||||||
| 2. Run the containers using `Docker Compose`. | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
Comment on lines
+8
to
+9
|
||||||||||||||||||||||||||||||||
| 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
AI
Feb 10, 2026
There was a problem hiding this comment.
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.
| cd mern/server | |
| cd mern/backend |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
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.
| cd mern/client | |
| cd mern/frontend |
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||||||
| services: | ||||||||||
| frontend: | ||||||||||
| build: ./frontend | ||||||||||
| ports: | ||||||||||
| - "5173:5173" | ||||||||||
| networks: | ||||||||||
| - mern | ||||||||||
|
||||||||||
| - mern | |
| - mern | |
| environment: | |
| - VITE_API_URL=http://backend:5050 |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
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.
| ports: | |
| - "27017:27017" |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
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.
| test: ["CMD", "mongosh", "--eval", "db.runCommand({ ping: 1 })"] | |
| test: ["CMD", "mongosh", "--quiet", "--eval", "db.runCommand({ ping: 1 })"] |
| 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"] |
There was a problem hiding this comment.
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.