Files

292 lines
8.2 KiB
YAML

# RuVector-Postgres Docker Compose Configuration
# Provides development, testing, and benchmarking services
#
# Usage:
# docker-compose up postgres # Start PostgreSQL with extension
# docker-compose up test-runner # Run tests
# docker-compose --profile benchmark up benchmark # Run benchmarks
#
# Build for specific PostgreSQL version:
# PG_VERSION=16 docker-compose build
version: '3.8'
# Build arguments shared across services
x-build-args: &build-args
PG_VERSION: ${PG_VERSION:-17}
RUST_VERSION: ${RUST_VERSION:-1.83}
# Common environment for test containers
x-test-env: &test-env
DATABASE_URL: postgres://ruvector:ruvector@postgres:5432/ruvector_test
RUST_LOG: ${RUST_LOG:-info}
RUST_BACKTRACE: ${RUST_BACKTRACE:-1}
PG_VERSION: ${PG_VERSION:-17}
# Common volume mounts for development
x-dev-volumes: &dev-volumes
- ../../..:/app:cached
- cargo_cache:/usr/local/cargo/registry
- cargo_git:/usr/local/cargo/git
- target_cache:/app/target
services:
# ===========================================================================
# PostgreSQL with RuVector Extension
# ===========================================================================
postgres:
build:
context: ../../..
dockerfile: crates/ruvector-postgres/docker/Dockerfile
args:
<<: *build-args
container_name: ruvector-postgres
hostname: postgres
ports:
- "${POSTGRES_PORT:-5432}:5432"
environment:
POSTGRES_USER: ${POSTGRES_USER:-ruvector}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-ruvector}
POSTGRES_DB: ${POSTGRES_DB:-ruvector_test}
POSTGRES_INITDB_ARGS: "--data-checksums"
# PostgreSQL performance tuning
POSTGRES_HOST_AUTH_METHOD: scram-sha-256
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
- ./postgresql.conf:/etc/postgresql/postgresql.conf:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-ruvector} -d ${POSTGRES_DB:-ruvector_test}"]
interval: 5s
timeout: 5s
retries: 10
start_period: 10s
networks:
- ruvector-network
deploy:
resources:
limits:
memory: 2G
reservations:
memory: 512M
restart: unless-stopped
# ===========================================================================
# Test Runner Container
# ===========================================================================
test-runner:
build:
context: ../../..
dockerfile: crates/ruvector-postgres/docker/test-runner/Dockerfile
args:
<<: *build-args
container_name: ruvector-test-runner
depends_on:
postgres:
condition: service_healthy
environment:
<<: *test-env
TEST_RESULTS_DIR: /test-results
JUNIT_OUTPUT: /test-results/junit.xml
volumes:
- ../../..:/app:cached
- cargo_cache:/usr/local/cargo/registry
- cargo_git:/usr/local/cargo/git
- target_cache:/app/target
- test_results:/test-results
networks:
- ruvector-network
working_dir: /app/crates/ruvector-postgres
command: ["/usr/local/bin/run-tests.sh"]
deploy:
resources:
limits:
memory: 4G
reservations:
memory: 1G
# ===========================================================================
# Benchmark Runner Container
# ===========================================================================
benchmark:
build:
context: ../../..
dockerfile: crates/ruvector-postgres/docker/benchmark/Dockerfile
args:
<<: *build-args
container_name: ruvector-benchmark
depends_on:
postgres:
condition: service_healthy
environment:
<<: *test-env
RESULTS_DIR: /benchmark-results
COMPARE_BASELINE: ${COMPARE_BASELINE:-false}
BASELINE_DIR: /baseline
BENCHMARK_FILTER: ${BENCHMARK_FILTER:-}
volumes:
- ../../..:/app:cached
- cargo_cache:/usr/local/cargo/registry
- cargo_git:/usr/local/cargo/git
- target_cache:/app/target
- benchmark_results:/benchmark-results
- ${BASELINE_DIR:-./baseline}:/baseline:ro
networks:
- ruvector-network
working_dir: /app/crates/ruvector-postgres
command: ["/usr/local/bin/run-benchmarks.sh"]
profiles:
- benchmark
deploy:
resources:
limits:
memory: 8G
reservations:
memory: 2G
# ===========================================================================
# Development Shell Container
# ===========================================================================
dev:
build:
context: ../../..
dockerfile: crates/ruvector-postgres/docker/test-runner/Dockerfile
args:
<<: *build-args
container_name: ruvector-dev
depends_on:
postgres:
condition: service_healthy
environment:
<<: *test-env
volumes:
*dev-volumes
networks:
- ruvector-network
working_dir: /app/crates/ruvector-postgres
command: ["bash"]
stdin_open: true
tty: true
profiles:
- dev
# ===========================================================================
# PostgreSQL Versions for Matrix Testing
# ===========================================================================
postgres-pg14:
build:
context: ../../..
dockerfile: crates/ruvector-postgres/docker/Dockerfile
args:
PG_VERSION: 14
RUST_VERSION: ${RUST_VERSION:-1.83}
container_name: ruvector-postgres-pg14
ports:
- "5414:5432"
environment:
POSTGRES_USER: ruvector
POSTGRES_PASSWORD: ruvector
POSTGRES_DB: ruvector_test
volumes:
- postgres_data_pg14:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ruvector"]
interval: 5s
timeout: 5s
retries: 10
networks:
- ruvector-network
profiles:
- matrix
postgres-pg15:
build:
context: ../../..
dockerfile: crates/ruvector-postgres/docker/Dockerfile
args:
PG_VERSION: 15
RUST_VERSION: ${RUST_VERSION:-1.83}
container_name: ruvector-postgres-pg15
ports:
- "5415:5432"
environment:
POSTGRES_USER: ruvector
POSTGRES_PASSWORD: ruvector
POSTGRES_DB: ruvector_test
volumes:
- postgres_data_pg15:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ruvector"]
interval: 5s
timeout: 5s
retries: 10
networks:
- ruvector-network
profiles:
- matrix
postgres-pg16:
build:
context: ../../..
dockerfile: crates/ruvector-postgres/docker/Dockerfile
args:
PG_VERSION: 16
RUST_VERSION: ${RUST_VERSION:-1.83}
container_name: ruvector-postgres-pg16
ports:
- "5416:5432"
environment:
POSTGRES_USER: ruvector
POSTGRES_PASSWORD: ruvector
POSTGRES_DB: ruvector_test
volumes:
- postgres_data_pg16:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ruvector"]
interval: 5s
timeout: 5s
retries: 10
networks:
- ruvector-network
profiles:
- matrix
# ===========================================================================
# Volumes
# ===========================================================================
volumes:
# PostgreSQL data volumes (per version)
postgres_data:
name: ruvector-postgres-data
postgres_data_pg14:
name: ruvector-postgres-data-pg14
postgres_data_pg15:
name: ruvector-postgres-data-pg15
postgres_data_pg16:
name: ruvector-postgres-data-pg16
# Cargo cache volumes (shared across containers)
cargo_cache:
name: ruvector-cargo-cache
cargo_git:
name: ruvector-cargo-git
target_cache:
name: ruvector-target-cache
# Test and benchmark results
test_results:
name: ruvector-test-results
benchmark_results:
name: ruvector-benchmark-results
# ===========================================================================
# Networks
# ===========================================================================
networks:
ruvector-network:
name: ruvector-network
driver: bridge
ipam:
config:
- subnet: 172.28.0.0/16