Skip to content

Commit

Permalink
Add MongoDB service to Docker Compose configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
AtilMohAmine committed Feb 11, 2024
1 parent 7b93e27 commit 2c5e7af
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DB_USER=root
DB_PASSWORD=123456
DB_NAME=chat_db
27 changes: 24 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
version: '3'

services:

mongodb:
image: mongo:latest
restart: unless-stopped
environment:
- MONGO_INITDB_ROOT_USERNAME=$DB_USER
- MONGO_INITDB_ROOT_PASSWORD=$DB_PASSWORD
- MONGO_INITDB_DATABASE=$DB_NAME
ports:
- "27017:27017"
volumes:
- db:/data/db

chat-server:
build: ./server
restart: unless-stopped
env_file: ./server/.env
environment:
- DATABASE_URI=mongodb://${DB_USER}:${DB_PASSWORD}@mongodb:27017/${DB_NAME}?authSource=admin
ports:
- "5000:5000"
depends_on:
- mongodb


chat-client:
build: ./client
restart: unless-stopped
env_file: ./client/.env
environment:
REACT_APP_SERVER_URL: http://chat-server:5000
- REACT_APP_SERVER_URL=http://chat-server:5000
ports:
- "3000:3000"
depends_on:
- chat-server
- chat-server

volumes:
db:

0 comments on commit 2c5e7af

Please sign in to comment.