-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
35 lines (31 loc) · 955 Bytes
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
services:
mongodb:
image: mongodb/mongodb-community-server:latest
container_name: mongodb
ports:
- "27017:27017" # Expose MongoDB port
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: secret
networks:
- express_api_network
volumes:
- mongodb_data:/data/db # Volume for persistent data
app:
build:
context: . # Directory containing the Dockerfile
dockerfile: dockerfile # Specify the Dockerfile name if it's not the default
container_name: express-ts-api
ports:
- "8080:8080" # Expose the app port
environment:
MONGO_URI: mongodb://admin:secret@mongodb:27017/collections?authSource=admin # Connection URI
depends_on:
- mongodb # Ensure MongoDB starts before the app
networks:
- express_api_network
networks:
express_api_network:
driver: bridge # Create a bridge network
volumes:
mongodb_data: