Files
awoooi/apps/api/docker-compose.test.yml
OG T e65d931e73
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 2m2s
fix(ci): B5 整合測試 DinD 修正 — 用 host bridge IP + published port
DinD 環境下 volume mount 和 compose 網路都不可靠:
- runner container 的路徑 ≠ host 路徑 (volume 失敗)
- compose 網路 IP 對 runner 不可路由

解法: host docker bridge (ip route default gateway) + postgres exposed port 15432
runner 直接用 /opt/api-venv/bin/pytest (host runner 上已安裝)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 13:03:25 +08:00

59 lines
1.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AWOOOI 整合測試用 Docker Compose
# ===================================
# 用途: CI 環境中提供完全隔離的 PostgreSQL + Redis
# 不用於生產環境
#
# 啟動: docker compose -f docker-compose.test.yml up -d
# 停止: docker compose -f docker-compose.test.yml down -v
#
# 2026-04-10 Claude Sonnet 4.6 Asia/Taipei
services:
postgres-test:
image: pgvector/pgvector:pg16
environment:
POSTGRES_DB: awoooi_test
POSTGRES_USER: awoooi
POSTGRES_PASSWORD: awoooi_test_2026
ports:
- "15432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U awoooi -d awoooi_test"]
interval: 5s
timeout: 3s
retries: 10
tmpfs:
- /var/lib/postgresql/data # 記憶體內 — 快 + 隔離
redis-test:
image: redis:7-alpine
ports:
- "16380:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
# 2026-04-10 Claude Sonnet 4.6 Asia/Taipei: 整合測試 runner
# 在 compose 網路內跑 pytesthostname=postgres-test 直連,不依賴 host venv
# Schema 由 CD workflow 用 compose exec psql 初始化(避免 DinD volume 路徑問題)
pytest-runner:
image: python:3.11-slim
working_dir: /workspace
volumes:
- .:/workspace
environment:
TEST_DATABASE_URL: "postgresql+asyncpg://awoooi:awoooi_test_2026@postgres-test:5432/awoooi_test?ssl=disable"
depends_on:
postgres-test:
condition: service_healthy
redis-test:
condition: service_healthy
command: >
sh -c "pip install -q uv &&
uv pip install -q --system -e '.[dev]' &&
pytest tests/integration/test_b5_core_flows.py -v --tb=short"
profiles:
- test # 只在明確指定 --profile test 時才啟動