-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompose.yaml
85 lines (81 loc) · 3.04 KB
/
compose.yaml
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
services:
### BACKEND (EXPRESS API)
express-api:
container_name: express-api
tty: true
init: true
restart: on-failure
healthcheck:
test: ["CMD-SHELL", "node", "/app/healthcheck.js"] # Check health endpoint for healthy service.
interval: 30s # Perform the health check every 30 seconds.
timeout: 10s # Consider the health check a failure if it takes more than 10 seconds.
retries: 5 # Retry the health check up to 5 times before considering the container unhealthy.
start_period: 5s # How long to wait after the container starts to run the first health check.
build:
context: backend
dockerfile: docker/Dockerfile
args:
- NODE_IMAGE_TAG=${NODE_IMAGE_TAG} # Node image tag
- BACKEND_PORT=${BACKEND_PORT}
env_file: .env
environment:
- MONGO_HOST=mongo
- BACKEND_URL=http://localhost:${BACKEND_PORT:-3200}
- RABBITMQ_URL=amqp://${RABBITMQ_DEFAULT_USER:-admin}:${RABBITMQ_DEFAULT_PASS:-pass}@rabbitmq:5672
ports:
- ${BACKEND_PORT:-3200}:3200
volumes:
- ./backend/src:/app/src
depends_on:
mongo:
condition: service_healthy
rabbitmq:
condition: service_healthy
networks:
- app-network
### MONGO DATABASE
mongo:
container_name: mongo
image: mongo:${MONGO_IMAGE_TAG:-8.0}
restart: unless-stopped
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_USER:-admin}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD:-password}
volumes:
- mongo_data:/data/db
ports:
- ${MONGO_EXTERNAL_PORT:-3300}:27017
networks:
- app-network
healthcheck:
test: ["CMD","mongosh", "--eval", "db.adminCommand('ping')"]
interval: 30s # Perform the health check every 30 seconds.
timeout: 10s # Consider the health check a failure if it takes more than 10 seconds.
retries: 5 # Retry the health check up to 5 times before considering the container unhealthy.
start_period: 10s # How long to wait after the container starts to run the first health check.
### RABBITMQ
rabbitmq:
image: rabbitmq:${RABBITMQ_IMAGE_TAG:-'4.0-alpine'}
container_name: rabbitmq
restart: always
ports:
- ${RABBITMQ_EXTERNAL_PORT:-3400}:5672 # RabbitMQ default port for clients
- '15672:15672' # RabbitMQ Management UI port
env_file: .env
volumes:
- rabbitmq_data:/var/lib/rabbitmq
command: ["bash", "-c", "chmod 400 /var/lib/rabbitmq/.erlang.cookie; rabbitmq-server"]
networks:
- app-network
healthcheck:
test: ["CMD-SHELL", "rabbitmqctl status || exit 1"]
interval: 30s # Perform the health check every 30 seconds.
timeout: 10s # Consider the health check a failure if it takes more than 10 seconds.
retries: 5 # Retry the health check up to 5 times before considering the container unhealthy.
start_period: 10s # How long to wait after the container starts to run the first health check.
volumes:
mongo_data:
rabbitmq_data:
networks:
app-network:
driver: bridge