-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
117 lines (111 loc) · 2.96 KB
/
Copy pathdocker-compose.yml
File metadata and controls
117 lines (111 loc) · 2.96 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
# =============================================================================
# Local development stack. Mirrors the production topology (web -> api -> db/cache)
# so "works on my machine" matches "works in the cluster".
# docker compose up --build
# Services are wired by name on a shared network; no host ports needed between them.
# =============================================================================
name: scalable-starter
services:
web:
build:
context: .
dockerfile: infra/docker/web.Dockerfile
target: dev
environment:
NODE_ENV: development
NEXT_PUBLIC_API_URL: http://localhost:8000
API_INTERNAL_URL: http://api:8000
ports:
- '3000:3000'
volumes:
- ./apps/web:/app/apps/web
- ./packages:/app/packages
- /app/node_modules
- /app/apps/web/.next
depends_on:
api:
condition: service_healthy
restart: unless-stopped
api:
build:
context: .
dockerfile: infra/docker/api.Dockerfile
target: dev
env_file: .env
environment:
DATABASE_URL: postgresql+asyncpg://app:app@postgres:5432/app
REDIS_URL: redis://redis:6379/0
LOG_FORMAT: console
ports:
- '8000:8000'
volumes:
- ./apps/api:/app
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrate:
condition: service_completed_successfully
healthcheck:
test:
[
'CMD',
'python',
'-c',
"import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8000/healthz').status==200 else 1)",
]
interval: 10s
timeout: 3s
retries: 5
start_period: 20s
restart: unless-stopped
# One-shot: apply DB migrations before the API starts, so a fresh `make up`
# yields a working /api/v1/items end-to-end. Runs to completion, then exits.
migrate:
build:
context: .
dockerfile: infra/docker/api.Dockerfile
target: dev
env_file: .env
environment:
DATABASE_URL: postgresql+asyncpg://app:app@postgres:5432/app
command: ['alembic', 'upgrade', 'head']
volumes:
- ./apps/api:/app
depends_on:
postgres:
condition: service_healthy
restart: 'no'
postgres:
image: postgres:17-alpine
environment:
POSTGRES_USER: app
POSTGRES_PASSWORD: app
POSTGRES_DB: app
ports:
- '5432:5432'
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U app -d app']
interval: 5s
timeout: 3s
retries: 10
restart: unless-stopped
redis:
image: redis:7-alpine
command: ['redis-server', '--appendonly', 'yes']
ports:
- '6379:6379'
volumes:
- redisdata:/data
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 5s
timeout: 3s
retries: 10
restart: unless-stopped
volumes:
pgdata:
redisdata: