generated from oleksandr-romashko/goit-pythonweb-hw-08
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.yaml
More file actions
122 lines (116 loc) · 3.21 KB
/
compose.yaml
File metadata and controls
122 lines (116 loc) · 3.21 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: goit-pythonweb-hw-10-contacts-manager
services:
api:
container_name: api-fastapi
depends_on:
db:
condition: service_healthy
api-cache:
condition: service_started
build:
context: .
dockerfile: Dockerfile
ports:
- "${WEB_PORT:-8000}:8000"
restart: always
# env_file:
# - .env
healthcheck:
# Test both healthchecker and docs:
# /api/healthchecker/ - verifies backend health (including DB connection)
# /docs/ - verifies swagger api docs page is served
test: [
"CMD-SHELL",
"wget -q --spider http://127.0.0.1:8000/api/healthchecker/ && \
wget -q --spider http://127.0.0.1:8000/docs/ || exit 1",
]
start_period: 10s
interval: 20s
timeout: 5s
retries: 3
security_opt:
- no-new-privileges:true
networks:
- backend-network
api-cache:
container_name: ${CACHE_HOST}
image: redis:alpine
restart: always
command: ["redis-server", "--requirepass", "${CACHE_PASSWORD}"]
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
security_opt:
- no-new-privileges:true
networks:
- backend-network
db:
container_name: ${DB_HOST}
image: postgres:17.5-alpine3.22
restart: always
# env_file:
# - .env
environment:
POSTGRES_USER: ${DB_ADMIN_USER}
POSTGRES_PASSWORD: ${DB_ADMIN_USER_PASSWORD}
POSTGRES_DB: ${DB_NAME}
PGDATA: /var/lib/postgresql/data/pgdata
healthcheck:
test:
[
"CMD-SHELL",
"pg_isready -U ${DB_ADMIN_USER:-postgres} -d ${DB_NAME:-mydb}",
]
start_period: 15s
interval: 10s
timeout: 5s
retries: 5
volumes:
- ./init/postgres/init.sh:/docker-entrypoint-initdb.d/init.sh:ro
- ./init/postgres/init.template.sql:/docker-entrypoint-initdb.d/templates/init.template.sql:ro
- db_data_volume:/var/lib/postgresql/data
security_opt:
- no-new-privileges:true
networks:
- backend-network
- db-network
db-admin-panel:
profiles: [tools]
container_name: db-admin-panel-pgadmin
depends_on:
db:
condition: service_healthy
image: dpage/pgadmin4:9.9
restart: unless-stopped
# env_file:
# - .env
ports:
- "${DB_ADMIN_PANEL_PORT:-5050}:80"
environment:
PGADMIN_DEFAULT_EMAIL: ${DB_ADMIN_PANEL_ACCESS_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${DB_ADMIN_PANEL_PASSWORD}
healthcheck:
test: ["CMD", "wget -q --spider http://127.0.0.1:80 || exit 1"]
interval: 30s
timeout: 5s
retries: 3
entrypoint: ["/bin/sh", "/pgadmin4/pgadmin_entrypoint.sh"]
volumes:
- ./init/pgadmin/pgadmin_custom_entrypoint.sh:/pgadmin4/pgadmin_entrypoint.sh:ro
- ./init/pgadmin/servers.template.json:/pgadmin4/servers.template.json:ro
- ./init/pgadmin/servers.json:/pgadmin4/servers.json
- db_admin_panel_data:/var/lib/pgadmin
security_opt:
- no-new-privileges:true
networks:
- db-network
networks:
backend-network:
driver: bridge
db-network:
driver: bridge
volumes:
db_data_volume:
db_admin_panel_data: