51 lines
1.6 KiB
YAML
51 lines
1.6 KiB
YAML
version: '3.8'
|
||
|
||
services:
|
||
# 服务一: DevStar
|
||
devstar:
|
||
# 我们不再拉取镜像
|
||
# image: mengning997/devstar-studio:latest
|
||
# pull_policy: always
|
||
# 我们告诉 Compose 在本地构建
|
||
build:
|
||
context: .
|
||
dockerfile: docker/Dockerfile.devstar #
|
||
|
||
image: devstar-e2e-test:latest #
|
||
pull_policy: never
|
||
ports:
|
||
- "80:3000"
|
||
- "2222:2222"
|
||
volumes:
|
||
# 挂载 Docker Socket,允许 DevStar 创建 Devcontainer
|
||
- /var/run/docker.sock:/var/run/docker.sock
|
||
# 挂载数据卷,使用相对路径,保证测试环境可移植
|
||
- ./tests/e2e/test-data/devstar_data:/var/lib/gitea
|
||
- ./tests/e2e/test-data/devstar_data:/etc/gitea
|
||
# 健康检查。test-runner 会等待这个检查通过
|
||
healthcheck:
|
||
test: ["CMD-SHELL", "curl -f http://localhost:3000/ || exit 1"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 30
|
||
# 服务二: Playwright
|
||
test-runner:
|
||
# 从 'tests/' 目录下的 Dockerfile 构建
|
||
build:
|
||
context: ./tests/e2e
|
||
# 等待 devstar 的 "healthcheck" 通过后,才启动
|
||
depends_on:
|
||
devstar:
|
||
condition: service_healthy
|
||
environment:
|
||
# 将 DevStar 的 URL 传给 Playwright
|
||
- DEVSTAR_URL=http://devstar:3000
|
||
volumes:
|
||
# 也挂载 Docker Socket
|
||
- /var/run/docker.sock:/var/run/docker.sock
|
||
# 将测试报告写回到宿主机的 ./reports 目录
|
||
- ./tests/e2e/reports:/app/playwright-report
|
||
# 覆盖默认命令,强制运行测试并生成我们想要的报告
|
||
command: >
|
||
npx playwright test
|