Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 2m2s
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>
59 lines
1.8 KiB
YAML
59 lines
1.8 KiB
YAML
# 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 網路內跑 pytest,hostname=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 時才啟動
|