-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yaml
80 lines (76 loc) · 1.73 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
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
services:
shortener_db:
image: postgres:latest
user: postgres
restart: always
networks:
- backend
env_file:
- ./config/docker.env
ports:
- "5432:5432"
healthcheck:
test: ["CMD", "pg_isready"]
interval: 10s
timeout: 10s
retries: 5
volumes:
- shortener_data:/var/lib/postgresql/shortener_data
app:
build:
context: .
dockerfile: cmd/shortener/Dockerfile
restart: always
ports:
- "9090:9090"
env_file:
- ./config/docker.env
healthcheck:
test: [ "CMD", "wget", "--spider", "--quiet", "app:9090/healthz" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
start_interval: 3s
depends_on:
shortener_db:
condition: service_healthy
migration:
condition: service_completed_successfully
networks:
- backend
cronjob:
build:
context: .
dockerfile: cmd/cronjob/Dockerfile
restart: always
env_file:
- ./config/docker.env
depends_on:
shortener_db:
condition: service_healthy
networks:
- backend
migration:
container_name: migration
image: alpine/curl:latest
depends_on:
shortener_db:
condition: service_healthy
env_file:
- ./config/docker.env
volumes:
- ./migrations:/migrations
entrypoint:
- /bin/sh
- -c
- |
curl -fsSL https://raw.githubusercontent.com/pressly/goose/master/install.sh | sh &&
goose -dir=/migrations postgres "postgres://$${POSTGRES_USER}:$${POSTGRES_PASSWORD}@$${POSTGRES_HOST}/$${POSTGRES_DB}?sslmode=disable" up
networks:
- backend
volumes:
shortener_data:
networks:
backend:
driver: bridge