-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
223 lines (214 loc) · 6.58 KB
/
Copy pathdocker-compose.yml
File metadata and controls
223 lines (214 loc) · 6.58 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# =============================================================================
# NLP2CMD - Docker Compose Configuration
# =============================================================================
# Services:
# - nlp2cmd: Main application
# - nlp2cmd-test: Test runner
# - nlp2cmd-dev: Development environment with hot reload
# - postgres: Database for integration tests
# - redis: Cache for LLM responses (optional)
# =============================================================================
version: "3.8"
services:
# ---------------------------------------------------------------------------
# Main Application
# ---------------------------------------------------------------------------
nlp2cmd:
build:
context: .
dockerfile: Dockerfile
target: runtime
image: nlp2cmd:latest@sha256:4f6f3422bc0d3fb294583530eb178fbad2f2e0377a7850d75f9156004ea064ed
container_name: nlp2cmd
environment:
- PYTHONPATH=/app/src
- NLP2CMD_ENV=production
- NLP2CMD_LOG_LEVEL=INFO
# LLM Configuration (optional)
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
volumes:
# Mount for persistent data
- nlp2cmd-data:/app/data
# Mount config if needed
- ./configs:/app/configs:ro
ports:
- "8000:8000"
healthcheck:
test: ["CMD", "python", "-c", "from nlp2cmd import get_registry; print('OK')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
restart: unless-stopped
networks:
- nlp2cmd-network
# ---------------------------------------------------------------------------
# Test Runner
# ---------------------------------------------------------------------------
nlp2cmd-test:
build:
context: .
dockerfile: Dockerfile
target: test
image: nlp2cmd:test@sha256:a2282e04d3dafb0819cebcdeb625a3f6e1dd378927e84f8ec6a3b88fb26f945c
container_name: nlp2cmd-test
environment:
- PYTHONPATH=/app/src
- NLP2CMD_ENV=test
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_USER=nlp2cmd
- POSTGRES_PASSWORD=nlp2cmd_test
- POSTGRES_DB=nlp2cmd_test
volumes:
- ./src:/app/src:ro
- ./tests:/app/tests:ro
- ./examples:/app/examples:ro
- test-results:/app/test-results
depends_on:
postgres:
condition: service_healthy
command: >
pytest tests/ -v
--tb=short
--junitxml=/app/test-results/junit.xml
--cov=nlp2cmd
--cov-report=html:/app/test-results/coverage
networks:
- nlp2cmd-network
profiles:
- test
# ---------------------------------------------------------------------------
# Development Environment
# ---------------------------------------------------------------------------
nlp2cmd-dev:
build:
context: .
dockerfile: Dockerfile
target: runtime
image: nlp2cmd:dev@sha256:b23e51f4834ab3fb140952be4fa2ab651edb2e8daa920b501846e3300f4598b8
container_name: nlp2cmd-dev
environment:
- PYTHONPATH=/app/src
- NLP2CMD_ENV=development
- NLP2CMD_LOG_LEVEL=DEBUG
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
volumes:
# Hot reload - mount source code
- ./src:/app/src
- ./tests:/app/tests
- ./examples:/app/examples
ports:
- "8001:8000"
stdin_open: true
tty: true
command: /bin/bash
networks:
- nlp2cmd-network
profiles:
- dev
# ---------------------------------------------------------------------------
# PostgreSQL for Integration Tests
# ---------------------------------------------------------------------------
postgres:
image: postgres:16-alpine@sha256:18cfe3ef5e6815560c98237d6216d1e5119702fb0f3894c8785dd58b8bbe5d73
container_name: nlp2cmd-postgres
environment:
- POSTGRES_USER=nlp2cmd
- POSTGRES_PASSWORD=nlp2cmd_test
- POSTGRES_DB=nlp2cmd_test
volumes:
- postgres-data:/var/lib/postgresql/data
- ./docker/init-db.sql:/docker-entrypoint-initdb.d/init.sql:ro
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U nlp2cmd -d nlp2cmd_test"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
- nlp2cmd-network
profiles:
- test
- dev
# ---------------------------------------------------------------------------
# Redis for Caching (Optional)
# ---------------------------------------------------------------------------
redis:
image: redis:7-alpine@sha256:65b8118ded1f9a62a4e7682a6176a874a59f241d0223ee7f6b0c25f1da77fc92
container_name: nlp2cmd-redis
command: redis-server --appendonly yes
volumes:
- redis-data:/data
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 3
networks:
- nlp2cmd-network
profiles:
- dev
- cache
# ---------------------------------------------------------------------------
# E2E Test Runner
# ---------------------------------------------------------------------------
nlp2cmd-e2e:
build:
context: .
dockerfile: Dockerfile
target: test
image: nlp2cmd:e2e@sha256:05606e8488c69c7baf544afe3c2b0d0b4c8a9f21ffa2b15408117434bfbdad37
container_name: nlp2cmd-e2e
environment:
- PYTHONPATH=/app/src
- NLP2CMD_ENV=e2e
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_USER=nlp2cmd
- POSTGRES_PASSWORD=nlp2cmd_test
- POSTGRES_DB=nlp2cmd_test
volumes:
- ./src:/app/src:ro
- ./tests:/app/tests:ro
- ./examples:/app/examples:ro
- e2e-results:/app/e2e-results
depends_on:
postgres:
condition: service_healthy
nlp2cmd:
condition: service_healthy
command: >
pytest tests/e2e/ -v
--tb=short
--junitxml=/app/e2e-results/junit.xml
networks:
- nlp2cmd-network
profiles:
- e2e
# =============================================================================
# Networks
# =============================================================================
networks:
nlp2cmd-network:
driver: bridge
name: nlp2cmd-network
# =============================================================================
# Volumes
# =============================================================================
volumes:
nlp2cmd-data:
name: nlp2cmd-data
postgres-data:
name: nlp2cmd-postgres-data
redis-data:
name: nlp2cmd-redis-data
test-results:
name: nlp2cmd-test-results
e2e-results:
name: nlp2cmd-e2e-results