-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.lifecycle.yml
More file actions
199 lines (191 loc) · 6.8 KB
/
Copy pathdocker-compose.lifecycle.yml
File metadata and controls
199 lines (191 loc) · 6.8 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
## Lifecycle test — full deploy → payment → removal cycle.
## Setup writes minimal config only; the test itself deploys contracts,
## registers provider, seeds DB, runs payment flow, then removes provider.
services:
stellar:
# Pinned build + protocol come from stellar-pin.env (SSOT). --protocol-version is a
# WORKAROUND for the image's broken default (protocol 25 on a stellar-core v27 image),
# which fails contract upload; remove it when a fixed image ships. See stellar-pin.env.
image: ${STELLAR_QUICKSTART_IMAGE}
command: --local --limits unlimited --protocol-version ${STELLAR_PROTOCOL_VERSION}
healthcheck:
test: >
curl -sf http://localhost:8000/soroban/rpc -X POST
-H "Content-Type: application/json"
-d '{"jsonrpc":"2.0","id":1,"method":"getHealth"}'
| grep -q healthy
interval: 5s
timeout: 5s
retries: 60
start_period: 10s
db:
image: postgres:18
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: devpass
POSTGRES_DB: postgres
volumes:
- ./test/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U admin -d postgres"]
interval: 3s
timeout: 3s
retries: 10
jaeger:
image: jaegertracing/all-in-one:latest
environment:
COLLECTOR_OTLP_ENABLED: "true"
SPAN_STORAGE_TYPE: badger
BADGER_EPHEMERAL: "false"
BADGER_DIRECTORY_KEY: /badger/keys
BADGER_DIRECTORY_VALUE: /badger/values
volumes:
- ./.traces/lifecycle:/badger
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:16686/api/services || exit 1"]
interval: 2s
timeout: 3s
retries: 15
setup:
image: denoland/deno:2.7.9
depends_on:
stellar:
condition: service_healthy
volumes:
- ./test:/app/test:ro
- shared-config:/config
working_dir: /app
entrypoint:
- sh
- -c
- |
cp test/setup-lifecycle.ts setup.ts && deno run --allow-all setup.ts
environment:
STELLAR_RPC_URL: http://stellar:8000/soroban/rpc
STELLAR_NETWORK_PASSPHRASE: "Standalone Network ; February 2017"
FRIENDBOT_URL: http://stellar:8000/friendbot
CONFIG_DIR: /config
PROVIDER_INTERNAL_PORT: "3000"
COUNCIL_INTERNAL_PORT: "8080"
provider:
image: denoland/deno:2.7.9
depends_on:
db:
condition: service_healthy
setup:
condition: service_completed_successfully
jaeger:
condition: service_healthy
volumes:
- ${PROVIDER_PLATFORM_PATH:-../provider-platform}:/app-src:ro
- shared-config:/config:ro
- ./test/provider-entrypoint.sh:/entrypoint.sh:ro
working_dir: /app
entrypoint: ["sh", "/entrypoint.sh"]
environment:
DATABASE_URL: postgresql://admin:devpass@db:5432/provider_platform_db
OTEL_DENO: "true"
OTEL_SERVICE_NAME: "provider-platform"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://jaeger:4318"
OTEL_EXPORTER_OTLP_PROTOCOL: "http/protobuf"
healthcheck:
test: >
sh -c 'deno eval "
const r = await fetch(\"http://localhost:3000/api/v1/stellar/auth?account=GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF\");
Deno.exit(r.status < 500 ? 0 : 1);
" 2>/dev/null'
interval: 5s
timeout: 5s
retries: 30
start_period: 10s
council:
image: denoland/deno:2.7.9
depends_on:
db:
condition: service_healthy
setup:
condition: service_completed_successfully
jaeger:
condition: service_healthy
volumes:
- ${COUNCIL_PLATFORM_PATH:-../council-platform}:/app-src:ro
- shared-config:/config:ro
- ./test/council-entrypoint.sh:/entrypoint.sh:ro
working_dir: /app
entrypoint: ["sh", "/entrypoint.sh"]
environment:
DATABASE_URL: postgresql://admin:devpass@db:5432/council_platform_db
OTEL_DENO: "true"
OTEL_SERVICE_NAME: "council-platform"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://jaeger:4318"
OTEL_EXPORTER_OTLP_PROTOCOL: "http/protobuf"
healthcheck:
test: >
sh -c 'deno eval "
const r = await fetch(\"http://localhost:8080/api/v1/health\");
Deno.exit(r.status === 200 ? 0 : 1);
" 2>/dev/null'
interval: 5s
timeout: 5s
retries: 30
start_period: 10s
test-runner:
image: denoland/deno:2.7.9
depends_on:
provider:
condition: service_healthy
council:
condition: service_healthy
jaeger:
condition: service_healthy
volumes:
- shared-config:/config:ro
- ./lifecycle:/lifecycle-src:ro
- ./lib:/lib-src:ro
- ./e2e:/e2e-src:ro
- ${WASM_DIR:-../soroban-core/target/wasm32v1-none/release}:/wasms:ro
working_dir: /app
entrypoint:
- sh
- -c
- |
mkdir -p lifecycle lib e2e
cp /lifecycle-src/*.ts lifecycle/ && cp /lifecycle-src/deno.json lifecycle/ && cp /lifecycle-src/deno.lock lifecycle/ 2>/dev/null || true
cp /lib-src/*.ts lib/
cp -r /lib-src/client lib/
cp /e2e-src/*.ts e2e/
cd lifecycle && deno install && cd ..
echo "Waiting for provider and Stellar..."
for i in $$(seq 1 60); do
provider_ok=false stellar_ok=false
PROBE_URL="$$PROVIDER_URL" deno eval "try { await fetch(Deno.env.get('PROBE_URL')); Deno.exit(0) } catch { Deno.exit(1) }" 2>/dev/null && provider_ok=true
PROBE_URL="$$STELLAR_RPC_URL" deno eval "
const url = Deno.env.get('PROBE_URL');
const r = await fetch(url, {method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({jsonrpc:'2.0',id:1,method:'getHealth'})});
const d = await r.json(); Deno.exit(d.result?.status==='healthy'?0:1)
" 2>/dev/null && stellar_ok=true
if [ "$$provider_ok" = true ] && [ "$$stellar_ok" = true ]; then
echo "Provider and Stellar are ready."
break
fi
if [ "$$i" -eq 60 ]; then echo "Services not ready after 120s"; exit 1; fi
sleep 2
done
exec deno run --allow-all lifecycle/main.ts
environment:
PROVIDER_URL: http://provider:3000
PROVIDER_API: http://provider:3000/api/v1
COUNCIL_URL: http://council:8080
COUNCIL_API: http://council:8080/api/v1
STELLAR_RPC_URL: http://stellar:8000/soroban/rpc
STELLAR_NETWORK_PASSPHRASE: "Standalone Network ; February 2017"
FRIENDBOT_URL: http://stellar:8000/friendbot
JAEGER_QUERY_URL: http://jaeger:16686
DATABASE_URL: postgresql://admin:devpass@db:5432/provider_platform_db
WASM_DIR: /wasms
OTEL_DENO: "true"
OTEL_SERVICE_NAME: "moonlight-e2e"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://jaeger:4318"
OTEL_EXPORTER_OTLP_PROTOCOL: "http/protobuf"
volumes:
shared-config: