Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
123 lines (114 loc) · 3.12 KB
/
Copy pathdocker-compose.yml
File metadata and controls
123 lines (114 loc) · 3.12 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
123
# version: '3.8'
services:
db:
image: postgres:15-alpine
container_name: db
environment:
POSTGRES_USER: ${DB_USER:-postgres}
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
POSTGRES_DB: ${DB_NAME:-interview_notes}
ports:
- "5454:5432" # Оставляем для доступа извне, убрать в продакшене
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- interview_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
api:
build: .
container_name: api
environment:
DB_HOST: db
DB_PORT: 5432
DB_USER: ${DB_USER:-postgres}
DB_PASSWORD: ${DB_PASSWORD:-postgres}
DB_NAME: ${DB_NAME:-interview_notes}
PYTHONUNBUFFERED: 1
ports:
- "8888:8888"
expose:
- "8888" # Делаем порт доступным только внутри сети
depends_on:
db:
condition: service_healthy
networks:
- interview_network
volumes:
- .:/app
command: uvicorn app.core.main:app --host 0.0.0.0 --port 8888 --reload
frontend:
build:
context: .
dockerfile: Dockerfile.frontend
container_name: frontend
ports:
- "5173:5173"
expose:
- "5173" # Делаем порт доступным только внутри сети
networks:
- interview_network
volumes:
- ./frontend:/app
- /app/node_modules
environment:
- VITE_API_URL=http://localhost:8888/api/v1
command: yarn dev --host 0.0.0.0
migrations:
container_name: migrations
build: .
environment:
DB_HOST: db
DB_PORT: 5432
DB_USER: ${DB_USER:-postgres}
DB_PASSWORD: ${DB_PASSWORD:-postgres}
DB_NAME: ${DB_NAME:-interview_notes}
PYTHONUNBUFFERED: 1
depends_on:
db:
condition: service_healthy
networks:
- interview_network
volumes:
- .:/app
command: |
sh -c "
# Ждем готовности базы
until pg_isready -h db -p 5432; do
echo 'Waiting for database...'
sleep 2
done
# Создаем таблицу alembic_version если её нет
PGPASSWORD=${DB_PASSWORD:-postgres} psql -h db -U ${DB_USER:-postgres} -d ${DB_NAME:-interview_notes} -c \"
CREATE TABLE IF NOT EXISTS alembic_version (
version_num VARCHAR(32) NOT NULL,
CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num)
);
\" || true
# Запускаем миграции
alembic upgrade head
"
nginx:
image: nginx:alpine
container_name: nginx
ports:
- "80:80"
- "443:443" # Для HTTPS
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/conf.d:/etc/nginx/conf.d:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- ./nginx/logs:/var/log/nginx
depends_on:
- api
- frontend
networks:
- interview_network
volumes:
postgres_data:
networks:
interview_network:
driver: bridge