-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose-ci.yml
85 lines (81 loc) · 2.27 KB
/
docker-compose-ci.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
version: '3.6'
services:
mysql:
container_name: 'ci-cd-db'
image: mariadb:10.11
restart: unless-stopped
environment:
MYSQL_DATABASE: ci-cd
MYSQL_ROOT_PASSWORD: docker
MYSQL_USER: ci-cd
MYSQL_PASSWORD: somepass
healthcheck:
test:
[
'CMD',
'mysqladmin',
'ping',
'-h',
'localhost',
'-uroot',
'-pdocker',
]
timeout: 45s
interval: 10s
retries: 5
ports:
- '127.0.0.1:3306:3306'
volumes:
- db_data:/var/lib/mysql
networks:
- main
api:
restart: unless-stopped
container_name: ci-cd-backend
depends_on:
mysql:
condition: service_healthy
environment:
NODE_ENV: dev
NESTJS_PORT: 3000
DATABASE_URL: 'mysql://ci-cd:somepass@ci-cd-db:3306/ci-cd'
image: marsalsans/ci-cd-backend:latest
networks:
- main
working_dir: /backend
command: npm run start
entrypoint: /bin/sh -c "npx prisma migrate reset --force && exec npm run start"
healthcheck:
test:
- CMD-SHELL
- |
if curl -fs http://localhost:3000/api/isAlive && \
curl -fs http://localhost:3000/api/counter; then \
exit 0; \
else \
exit 1; \
fi
timeout: 5s
interval: 10s
retries: 5
# Usamos el extra hosts para poder hacer el curl del healthcheck
extra_hosts:
- 'host.docker.internal:host-gateway'
front:
restart: unless-stopped
image: marsalsans/ci-cd-frontend:latest
container_name: ci-cd-front
depends_on:
api:
condition: service_healthy
ports:
- '127.0.0.1:8000:80'
networks:
- main
working_dir: /usr/share/nginx/html
networks:
main:
driver: bridge
volumes:
db_data:
driver: local