-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
85 lines (78 loc) · 1.96 KB
/
Copy pathdocker-compose.yml
File metadata and controls
85 lines (78 loc) · 1.96 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
version: '3.9'
services:
web:
build:
context: ./app
dockerfile: Dockerfile-web # Specify the Dockerfile for the app
container_name: flask_app
ports:
- "80:5000" # Expose the web server to the outside world
volumes:
- .:/app
environment:
- FLASK_ENV=development
- FLASK_APP=web_main.py
depends_on:
- db # Depends on the app's database
networks:
- app_net
- api_net
api:
build:
context: ./api
dockerfile: Dockerfile-api # Specify the Dockerfile for the API
container_name: flask_api
ports:
- "6000:6000" # Expose the web server to the outside world
# expose:
# - "6000" # Expose the API only to services inside the Docker network
volumes:
- .:/api
environment:
- FLASK_ENV=development
- FLASK_APP=api_main.py
depends_on:
- db-api # Depends on the API's database
networks:
- api_net
- app_net
db:
image: mongo:latest
container_name: mongo_app_db
expose:
- "27017" # Expose the DB only to services inside the Docker network
volumes:
- mongo-app-data:/data/db
networks:
- app_net
db-api:
image: mongo:latest
container_name: mongo_api_db
expose:
- "27018" # Expose the API's DB only to services inside the Docker network
volumes:
- mongo-api-data:/data/db
networks:
- api_net
test:
build:
context: ./app # Reuse the same context as web
dockerfile: Dockerfile-test # Use a separate Dockerfile for testing
container_name: flask_test
volumes:
- .:/app
command: ["python", "-m", "unittest", "discover", "-s", "/app/app/tests"]
depends_on:
- web
- api
networks:
- app_net
- api_net
volumes:
mongo-app-data:
mongo-api-data:
networks:
app_net:
driver: bridge # Network for web app and its database
api_net:
driver: bridge # Separate network for API and its database