-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
133 lines (119 loc) · 3.62 KB
/
docker-compose.yml
File metadata and controls
133 lines (119 loc) · 3.62 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
version: '3.8'
services:
# PostgreSQL Database (Optional - only starts if DB_TEST=true)
postgres:
image: postgres:15-alpine
container_name: playwright-postgres
environment:
POSTGRES_USER: ${DB_USER:-postgres}
POSTGRES_PASSWORD: ${DB_PASSWORD:-password}
POSTGRES_DB: ${DB_NAME:-testdb}
ports:
- "${DB_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres}"]
interval: 5s
timeout: 5s
retries: 5
networks:
- playwright-network
profiles:
- with-db
# Redis Cache (Optional - only starts if needed)
redis:
image: redis:7-alpine
container_name: playwright-redis
ports:
- "${REDIS_PORT:-6379}:6379"
command: redis-server --appendonly yes
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
networks:
- playwright-network
profiles:
- with-redis
# Playwright Test Runner
playwright-tests:
build:
context: .
dockerfile: Dockerfile
container_name: playwright-tests
environment:
# Application settings
BASE_URL: ${BASE_URL:-https://example.com}
TEST_USERNAME: ${TEST_USERNAME:-test_user}
TEST_PASSWORD: ${TEST_PASSWORD:-test_password}
# Browser settings
BROWSER: ${BROWSER:-chromium}
HEADLESS: ${HEADLESS:-true}
VIEWPORT_WIDTH: ${VIEWPORT_WIDTH:-1920}
VIEWPORT_HEIGHT: ${VIEWPORT_HEIGHT:-1080}
BROWSER_LOCALE: ${BROWSER_LOCALE:-en-US}
USER_AGENT: ${USER_AGENT:-Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36}
# Test execution
PYTEST_WORKERS: ${PYTEST_WORKERS:-auto}
TIMEOUT: ${TIMEOUT:-30000}
SCREENSHOT_ON_FAILURE: ${SCREENSHOT_ON_FAILURE:-true}
SCREENSHOTS_DIR: ${SCREENSHOTS_DIR:-screenshots}
# Database settings (if with-db profile is active)
DB_TEST: ${DB_TEST:-false}
DB_TYPE: ${DB_TYPE:-postgresql}
DB_HOST: postgres
DB_PORT: 5432
DB_NAME: ${DB_NAME:-testdb}
DB_USER: ${DB_USER:-postgres}
DB_PASSWORD: ${DB_PASSWORD:-password}
# Redis settings (if with-redis profile is active)
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_DB: ${REDIS_DB:-0}
# API settings
API_BASE_URL: ${API_BASE_URL:-}
API_BEARER_TOKEN: ${API_BEARER_TOKEN:-}
API_KEY: ${API_KEY:-}
API_USERNAME: ${API_USERNAME:-}
API_PASSWORD: ${API_PASSWORD:-}
# Notifications
DISCORD_WEBHOOK_URL: ${DISCORD_WEBHOOK_URL:-}
# Python settings
PYTHONPATH: /app
PYTHONUNBUFFERED: 1
volumes:
# Mount source code for development
- ./tests:/app/tests
- ./pages:/app/pages
- ./helpers:/app/helpers
- ./utils:/app/utils
- ./conftest.py:/app/conftest.py
- ./pytest.ini:/app/pytest.ini
# Mount reports and screenshots
- ./reports:/app/reports
- ./screenshots:/app/screenshots
# Preserve downloads
- ./downloads:/app/downloads
depends_on:
postgres:
condition: service_healthy
required: false
redis:
condition: service_healthy
required: false
networks:
- playwright-network
# Uncomment to run specific test commands
# command: pytest tests/ -v --alluredir=reports/allure-results
# command: pytest tests/test_ui_examples.py -v
# command: pytest tests/ -n auto -v
networks:
playwright-network:
driver: bridge
volumes:
postgres_data:
redis_data: