-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
122 lines (114 loc) · 4.52 KB
/
Copy pathdocker-compose.yml
File metadata and controls
122 lines (114 loc) · 4.52 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
# docker-compose.yml for ling-base local development & testing.
#
# Usage:
# docker compose up -d redis # Start Redis for stats/lock/limiter tests
# docker compose run test # Run full test suite in container
# docker compose run lint # Run golangci-lint
# docker compose run vuln # Run govulncheck
# docker compose down # Stop all services
services:
# ──────────────────────────────────────────────
# Redis: for stats/lock/limiter/cache tests
# ──────────────────────────────────────────────
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
command: redis-server --appendonly yes
# ──────────────────────────────────────────────
# PostgreSQL: for lock/postgres, migration tests
# ──────────────────────────────────────────────
postgres:
image: postgres:16-alpine
ports:
- "5432:5432"
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
volumes:
- pg-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U test"]
interval: 5s
timeout: 3s
retries: 5
# ──────────────────────────────────────────────
# MySQL: for lock/mysql tests
# ──────────────────────────────────────────────
mysql:
image: mysql:8
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: test
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: test
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 5s
timeout: 3s
retries: 10
# ──────────────────────────────────────────────
# Test runner: full test suite
# ──────────────────────────────────────────────
test:
build:
context: .
target: tester
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
environment:
REDIS_ADDR: redis:6379
POSTGRES_DSN: postgres://test:test@postgres:5432/test?sslmode=disable
MYSQL_DSN: test:test@tcp(mysql:3306)/test
command: make check
profiles: ["test"]
# ──────────────────────────────────────────────
# Lint runner
# ──────────────────────────────────────────────
lint:
build:
context: .
target: tester
command: golangci-lint run --timeout 10m ./...
profiles: ["lint"]
# ──────────────────────────────────────────────
# Vulnerability scanner
# ──────────────────────────────────────────────
vuln:
build:
context: .
target: tester
command: |
bash -c "for dir in $$(find . -name go.mod -not -path './go.mod' -print0 | xargs -0 -n1 dirname | sed 's|^\./||' | sort); do
echo '==> govulncheck: '$$dir
(cd $$dir && govulncheck ./... 2>&1) || true
done"
profiles: ["vuln"]
# ──────────────────────────────────────────────
# lingcli: scaffolding tool
# ──────────────────────────────────────────────
cli:
build:
context: .
target: cli
entrypoint: ["lingcli"]
profiles: ["cli"]
volumes:
redis-data:
pg-data:
mysql-data: