-
Notifications
You must be signed in to change notification settings - Fork 309
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
213 lines (206 loc) · 9.7 KB
/
docker-compose.yml
File metadata and controls
213 lines (206 loc) · 9.7 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# =============================================================================
# Docker Compose — Copilot Metrics Viewer
# =============================================================================
#
# This file supports two main use cases:
#
# 1. LOCAL DEVELOPMENT — Run the app with a database for realistic testing
# 2. TESTING — Run Playwright E2E tests (mock mode and full storage pipeline)
#
# ─── Quick Start ─────────────────────────────────────────────────────────────
#
# Run the app with mock data (no GitHub token needed):
# docker compose up web
# → Open http://localhost:3000/orgs/your-org?mock=true
#
# Run the app with real GitHub data (direct API, no DB):
# export NUXT_GITHUB_TOKEN=github_pat_...
# export NUXT_PUBLIC_GITHUB_ORG=your-org
# export NUXT_PUBLIC_IS_DATA_MOCKED=false
# docker compose up web
# → Open http://localhost:3000/orgs/your-org
#
# Run the app with historical mode (DB-backed, sync-on-miss):
# export NUXT_GITHUB_TOKEN=github_pat_...
# export NUXT_PUBLIC_GITHUB_ORG=your-org
# export NUXT_PUBLIC_IS_DATA_MOCKED=false
# export ENABLE_HISTORICAL_MODE=true
# docker compose up db web
# → First request auto-syncs from API to DB; subsequent requests read from DB
#
# Run a one-time sync to populate the database:
# docker compose run --rm sync
#
# ─── Testing ─────────────────────────────────────────────────────────────────
#
# Run all Playwright E2E tests (mock data, 3 browsers):
# docker compose run --rm playwright
#
# Run full storage pipeline E2E test (sync → DB → dashboard):
# docker compose run --rm sync-seed # Phase 1: seed DB with mock data
# docker compose run --rm playwright-storage # Phase 2: verify dashboard reads from DB
#
# ─── Services Overview ───────────────────────────────────────────────────────
#
# db — PostgreSQL 15 (data persistence)
# web — Main app (Nuxt 3, port 3000 → container port 80)
# sync — Standalone sync service (downloads metrics → PostgreSQL)
# playwright — E2E tests with mock data (test profile)
# sync-seed — Seeds DB with mock data for storage E2E (test profile)
# playwright-storage — E2E tests reading from DB, no GitHub token (test profile)
#
# ─── Environment Variables ───────────────────────────────────────────────────
#
# NUXT_PUBLIC_GITHUB_ORG — Target GitHub organization
# NUXT_PUBLIC_IS_DATA_MOCKED — "true" for mock data, "false" for real API
# NUXT_GITHUB_TOKEN — GitHub PAT (fine-grained, "Copilot metrics" permission)
# ENABLE_HISTORICAL_MODE — "true" to read from DB with sync-on-miss
# USE_LEGACY_API — set to "true" to use deprecated /copilot/metrics endpoint
# NUXT_SESSION_PASSWORD — Session secret (min 32 chars, auto-set below)
# DATABASE_URL — PostgreSQL connection string (auto-set for docker-compose)
#
# =============================================================================
services:
# ─── Database ────────────────────────────────────────────────────────────
# PostgreSQL for persistent metrics storage.
# Used by: web (when ENABLE_HISTORICAL_MODE=true), sync service.
# Data persisted in the postgres_data volume.
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: copilot_metrics
POSTGRES_USER: metrics_user
POSTGRES_PASSWORD: metrics_password
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U metrics_user -d copilot_metrics"]
interval: 5s
timeout: 3s
retries: 5
# ─── Web Application ────────────────────────────────────────────────────
# Main Nuxt 3 dashboard. Accessible at http://localhost:3000.
# Modes:
# - Mock data: IS_DATA_MOCKED=true (default, no token needed)
# - Direct API: IS_DATA_MOCKED=false, token required
# - Historical (DB): IS_DATA_MOCKED=false, ENABLE_HISTORICAL_MODE=true
# Reads from PostgreSQL, auto-syncs missing data from API.
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:80"
environment:
- NUXT_PUBLIC_SCOPE=organization
- NUXT_PUBLIC_GITHUB_ORG=${NUXT_PUBLIC_GITHUB_ORG:-your-org}
- NUXT_PUBLIC_IS_DATA_MOCKED=${NUXT_PUBLIC_IS_DATA_MOCKED:-true}
- NUXT_SESSION_PASSWORD=${NUXT_SESSION_PASSWORD:-at_least_32_characters_long_password_here}
# API mode: "new" (download-based, default) or "legacy" (deprecated April 2026)
- USE_LEGACY_API=${USE_LEGACY_API:-false}
- ENABLE_HISTORICAL_MODE=${ENABLE_HISTORICAL_MODE:-false}
# GitHub token — required unless using mock data
- NUXT_GITHUB_TOKEN=${NUXT_GITHUB_TOKEN:-}
# PostgreSQL — used when ENABLE_HISTORICAL_MODE=true
- DATABASE_URL=postgresql://metrics_user:metrics_password@db:5432/copilot_metrics
# Disable built-in scheduled sync (run separately via sync service)
- SYNC_ENABLED=false
# Note: DB is only needed when ENABLE_HISTORICAL_MODE=true.
# For direct API or mock mode, just run: docker compose up web
# ─── Sync Service ───────────────────────────────────────────────────────
# Standalone container that downloads metrics from GitHub API and stores
# them to PostgreSQL. Run on-demand or via cron.
# Usage: docker compose run --rm sync
sync:
build:
context: .
dockerfile: Dockerfile.sync
environment:
- NUXT_PUBLIC_SCOPE=organization
- NUXT_PUBLIC_GITHUB_ORG=${NUXT_PUBLIC_GITHUB_ORG:-your-org}
- NUXT_GITHUB_TOKEN=${NUXT_GITHUB_TOKEN:-}
- NUXT_PUBLIC_IS_DATA_MOCKED=${NUXT_PUBLIC_IS_DATA_MOCKED:-false}
- USE_LEGACY_API=${USE_LEGACY_API:-false}
- DATABASE_URL=postgresql://metrics_user:metrics_password@db:5432/copilot_metrics
- SYNC_ENABLED=true
depends_on:
db:
condition: service_healthy
# ─── E2E Tests (Mock Mode) ──────────────────────────────────────────────
# Runs all Playwright E2E tests using mock data (no GitHub token needed).
# Tests run across 3 browsers: chromium, firefox, webkit.
# Usage: docker compose run --rm playwright
playwright:
build:
context: .
dockerfile: Dockerfile
args:
mode: playwright
environment:
- NUXT_PUBLIC_IS_DATA_MOCKED=true
- NUXT_PUBLIC_SCOPE=organization
- NUXT_PUBLIC_GITHUB_ORG=mocked-org
- NUXT_SESSION_PASSWORD=at_least_32_characters_long_password_here
- NITRO_PORT=3000
volumes:
- ./test-results:/test-results
profiles:
- test
# ─── E2E Tests: Storage Pipeline ────────────────────────────────────────
# Two-phase E2E test verifying the full data pipeline:
# Phase 1 (sync-seed): Writes mock data to PostgreSQL
# Phase 2 (playwright-storage): Reads from PostgreSQL, no GitHub token
#
# Usage:
# docker compose run --rm sync-seed # Phase 1
# docker compose run --rm playwright-storage # Phase 2
#
# Both services share the same PostgreSQL database. Phase 1 must run first.
playwright-storage:
build:
context: .
dockerfile: Dockerfile
args:
mode: playwright
environment:
- NUXT_PUBLIC_IS_DATA_MOCKED=false
- NUXT_PUBLIC_SCOPE=organization
- NUXT_PUBLIC_GITHUB_ORG=storage-test-org
- NUXT_SESSION_PASSWORD=at_least_32_characters_long_password_here
- ENABLE_HISTORICAL_MODE=true
- DATABASE_URL=postgresql://metrics_user:metrics_password@db:5432/copilot_metrics
- NITRO_PORT=3000
entrypoint: ["npx", "playwright", "test", "-c", "playwright.docker.config.ts", "--workers", "1", "--grep", "@storage"]
depends_on:
db:
condition: service_healthy
volumes:
- ./test-results:/test-results
profiles:
- test
sync-seed:
build:
context: .
dockerfile: Dockerfile
args:
mode: playwright
environment:
- NUXT_PUBLIC_IS_DATA_MOCKED=true
- NUXT_PUBLIC_SCOPE=organization
- NUXT_PUBLIC_GITHUB_ORG=storage-test-org
- NUXT_SESSION_PASSWORD=at_least_32_characters_long_password_here
- ENABLE_HISTORICAL_MODE=true
- DATABASE_URL=postgresql://metrics_user:metrics_password@db:5432/copilot_metrics
- NITRO_PORT=3000
entrypoint: ["npx", "playwright", "test", "-c", "playwright.docker.config.ts", "--workers", "1", "--grep", "@seed"]
depends_on:
db:
condition: service_healthy
profiles:
- test
# ─── Volumes ───────────────────────────────────────────────────────────────
# postgres_data — PostgreSQL data directory
volumes:
postgres_data: