-
Notifications
You must be signed in to change notification settings - Fork 282
Expand file tree
/
Copy pathdocker-compose.test.yml
More file actions
114 lines (110 loc) · 4.02 KB
/
docker-compose.test.yml
File metadata and controls
114 lines (110 loc) · 4.02 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
# ============================================================================
# Mirix Test Infrastructure Docker Compose
# ============================================================================
# Ephemeral PostgreSQL and Redis containers for running tests in isolation.
#
# Usage:
# # Recommended: Use the test script (handles setup, teardown, and environment)
# ./scripts/run_tests_with_docker.sh
#
# # Or manually:
# # Start test infrastructure
# docker-compose -f docker-compose.test.yml up -d
#
# # Run tests (they'll connect to the test database)
# pytest tests/test_raw_memory.py -v
#
# # Stop and remove containers (data is ephemeral - no volumes)
# docker-compose -f docker-compose.test.yml down
#
# Environment Variables:
# Tests will use these connection strings automatically:
# - MIRIX_PG_URI=postgresql+pg8000://test:test@localhost:5433/mirix_test
# - MIRIX_REDIS_HOST=localhost
# - MIRIX_REDIS_PORT=6380
# ============================================================================
services:
# ==========================================================================
# Ephemeral PostgreSQL for Testing
# ==========================================================================
test_db:
image: ankane/pgvector:v0.5.1
container_name: mirix_test_db
restart: "no" # Don't restart - tests should control lifecycle
environment:
- POSTGRES_USER=test
- POSTGRES_PASSWORD=test
- POSTGRES_DB=mirix_test
ports:
- "5433:5432" # Different port to avoid conflicts with main DB
volumes:
# Mount init.sql to set up extensions (pgvector, uuid-ossp, pg_trgm)
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
# NO persistent volumes - ephemeral database, data is lost when container stops
healthcheck:
test: ["CMD-SHELL", "pg_isready -U test -d mirix_test"]
interval: 2s
timeout: 2s
retries: 10
start_period: 5s
# ==========================================================================
# Ephemeral Redis for Testing (optional)
# ==========================================================================
test_redis:
image: redis/redis-stack-server:latest
container_name: mirix_test_redis
restart: "no"
ports:
- "6380:6379" # Different port to avoid conflicts
# NO volumes - ephemeral Redis, data is lost when container stops
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 2s
timeout: 2s
retries: 10
start_period: 2s
# ==========================================================================
# Test API Server (for integration tests)
# ==========================================================================
test_server:
build:
context: .
dockerfile: Dockerfile
container_name: mirix_test_server
restart: "no"
depends_on:
test_db:
condition: service_healthy
test_redis:
condition: service_healthy
ports:
- "${SERVER_PORT:-8000}:8000" # Expose on configurable port (default 8000)
command: ["uvicorn", "mirix.server.rest_api:app", "--host", "0.0.0.0", "--port", "8000"]
env_file:
- .env # Load API keys and other secrets from .env file
environment:
# Connect to test database and Redis
- MIRIX_PG_HOST=test_db
- MIRIX_PG_PORT=5432
- MIRIX_PG_USER=test
- MIRIX_PG_PASSWORD=test
- MIRIX_PG_DB=mirix_test
- MIRIX_PG_URI=postgresql+pg8000://test:test@test_db:5432/mirix_test
- MIRIX_REDIS_ENABLED=true
- MIRIX_REDIS_HOST=test_redis
- MIRIX_REDIS_PORT=6379
- MIRIX_LANGFUSE_ENABLED=false
- MIRIX_LOG_LEVEL=WARNING
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 5s
timeout: 3s
retries: 10
start_period: 15s
# ============================================================================
# Networks
# ============================================================================
networks:
default:
name: mirix_test_network
driver: bridge