-
Notifications
You must be signed in to change notification settings - Fork 7
/
docker-compose.yaml
53 lines (48 loc) · 1.47 KB
/
docker-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
version: "3"
services:
db:
image: mysql:latest
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: 12345
MYSQL_DATABASE: testemed
volumes:
- ./mysql:/var/lib/mysql
networks:
- my-networks
app:
build: .
ports:
- "3000:3000"
depends_on:
- db
- redis
environment:
- DB_HOST=db
# irá montar a pasta atual para dentro do container em "/app".
volumes:
- .:/app
# comando "sh -c" executa o comando npm install, npm start e o watch, tudo em um único shell. O comando watch é executado em um loop infinito usando o comando inotifywait, que irá monitorar alterações em qualquer arquivo na pasta "/app" e automaticamente executará o comando "npm start" quando houver alterações.
command: sh -c "bash /app/wait-for-it.sh -t 0 db:3306 -- npm install && npm start && while inotifywait -r -e modify /app; do npm start; done"
networks:
- my-networks
seed:
build: .
depends_on:
- db
volumes:
- ./population.sql:/docker-entrypoint-initdb.d/population.sql
restart: on-failure
command: sh -c "sleep 50 && apt-get update > /dev/null && apt-get install -y default-mysql-client > /dev/null && mysql -uroot -p12345 -h db < /docker-entrypoint-initdb.d/population.sql && sleep 5"
networks:
- my-networks
redis:
image: redis:7
ports:
- "6379:6379"
networks:
- my-networks
networks:
my-networks:
driver: bridge