-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
71 lines (66 loc) · 1.78 KB
/
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
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
version: '3.8'
services:
database:
image: postgres:15
container_name: lanchonete_database
restart: always
environment:
TZ: 'America/Sao_Paulo'
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
ports:
- "5432:5432"
volumes:
- ./tmp/database:/var/lib/postgresql/data
healthcheck: #verificação da saúde do container
test: ["CMD-SHELL", "pg_isready -U postgres"] #testa o postgres com o comando esperando uma resposta
interval: 5s #intervalo de tempo
timeout: 5s #tempo maximo de espera
retries: 5 # numero de tentativas
networks:
- lanchonete_network
mock_pagamento:
build: ./mock_pagamento
image: mock_pagamento
container_name: lanchonete_pagamento
ports:
- "3001:3001"
env_file:
- ./mock_pagamento/.env # for all on docker use .env.docker
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:3001/ping || exit 1
interval: 10s
timeout: 5s
retries: 5
start_period: 15s
networks:
- lanchonete_network
app:
build:
context: .
dockerfile: Dockerfile
image: lanchonete-app:latest
container_name: lanchonete_app
ports:
- "3000:3000"
env_file:
- .env.docker
depends_on:
mock_pagamento:
condition: service_healthy
database:
condition: service_healthy #inicia o container do app só quando o postgres disser que está healthy
healthcheck:
test: ["CMD-SHELL", "curl http://localhost:3000/health || exit 1"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
networks:
- lanchonete_network
profiles:
- all
networks:
lanchonete_network:
driver: bridge