-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
234 lines (216 loc) · 7.97 KB
/
docker-compose.yaml
File metadata and controls
234 lines (216 loc) · 7.97 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
services:
# ============================================================================
# SCARCITY TEST RUNNER
# ============================================================================
scarcity-tests:
build: .
depends_on:
freebird-issuer:
condition: service_started
freebird-verifier:
condition: service_started
witness-gateway:
condition: service_started
hypertoken-relay:
condition: service_started
environment:
- FREEBIRD_ISSUER_URL=http://freebird-issuer:8081
- FREEBIRD_VERIFIER_URL=http://freebird-verifier:8082
- WITNESS_GATEWAY_URL=http://witness-gateway:8080
- HYPERTOKEN_RELAY_URL=ws://hypertoken-relay:3000
# Wait for all services to be reachable before running tests
command: >
sh -c "
echo '⏳ Waiting for services...' &&
while ! nc -z freebird-issuer 8081; do sleep 1; done &&
while ! nc -z freebird-verifier 8082; do sleep 1; done &&
while ! nc -z witness-gateway 8080; do sleep 1; done &&
while ! nc -z hypertoken-relay 3000; do sleep 1; done &&
echo '✅ Services up! Running tests...' &&
npm test
"
# ============================================================================
# SCARCITY WEB SERVICES
# ============================================================================
scarcity-web-wallet:
build: .
ports:
- "3000:3000"
depends_on:
freebird-issuer:
condition: service_started
freebird-verifier:
condition: service_started
witness-gateway:
condition: service_started
hypertoken-relay:
condition: service_started
environment:
- PORT=3000
- FREEBIRD_ISSUER_URL=http://freebird-issuer:8081
- FREEBIRD_VERIFIER_URL=http://freebird-verifier:8082
- WITNESS_GATEWAY_URL=http://witness-gateway:8080
- HYPERTOKEN_RELAY_URL=ws://hypertoken-relay:3000
volumes:
- scarcity-data:/root/.scarcity
command: ["npm", "run", "web"]
scarcity-explorer:
build: .
ports:
- "3001:3001"
depends_on:
freebird-issuer:
condition: service_started
freebird-verifier:
condition: service_started
witness-gateway:
condition: service_started
hypertoken-relay:
condition: service_started
environment:
- PORT=3001
- FREEBIRD_ISSUER_URL=http://freebird-issuer:8081
- FREEBIRD_VERIFIER_URL=http://freebird-verifier:8082
- WITNESS_GATEWAY_URL=http://witness-gateway:8080
- HYPERTOKEN_RELAY_URL=ws://hypertoken-relay:3000
volumes:
- scarcity-data:/root/.scarcity
command: ["npm", "run", "explorer"]
# ============================================================================
# FREEBIRD CLUSTER
# ============================================================================
freebird-issuer:
image: ghcr.io/flammafex/freebird-issuer:latest
ports:
- "8081:8081"
environment:
- ISSUER_ID=issuer:docker:v1
- BIND_ADDR=0.0.0.0:8081
# Combined Sybil resistance: requires BOTH progressive trust AND proof of diversity
- SYBIL_RESISTANCE=combined
- SYBIL_COMBINED_MODE=and
- SYBIL_COMBINED_MECHANISMS=progressive_trust,proof_of_diversity
- ADMIN_API_KEY=dev-admin-key-must-be-at-least-32-characters-long
- ISSUER_SK_PATH=/tmp/issuer_sk.bin
- KEY_ROTATION_STATE_PATH=/tmp/key_state.json
freebird-verifier:
image: ghcr.io/flammafex/freebird-verifier:latest
ports:
- "8082:8082"
depends_on:
- freebird-redis
environment:
- BIND_ADDR=0.0.0.0:8082
- ISSUER_URL=http://freebird-issuer:8081/.well-known/issuer
- REDIS_URL=redis://freebird-redis:6379
freebird-redis:
image: redis:alpine
# ============================================================================
# WITNESS CLUSTER
# ============================================================================
witness-setup:
build:
context: https://github.com/flammafex/witness.git
target: witness-node
volumes:
- witness-config:/data
entrypoint: ["/bin/bash", "-c"]
command:
- |
#if [ -f /data/network.json ]; then
# echo "✅ Configuration already exists. Skipping setup."
# exit 0
#fi
echo "🔧 Generating Witness Keys..."
# Generate witness-1
OUT1=$$(witness-node --generate-key)
PRIV1=$$(echo "$$OUT1" | grep "Private key:" | awk '{print $$3}')
PUB1=$$(echo "$$OUT1" | grep "Public key:" | awk '{print $$3}')
echo "{\"id\": \"witness-1\", \"private_key\": \"$$PRIV1\", \"port\": 4001, \"network_id\": \"docker-net\", \"max_clock_skew\": 300}" > /data/witness1.json
# Generate witness-2
OUT2=$$(witness-node --generate-key)
PRIV2=$$(echo "$$OUT2" | grep "Private key:" | awk '{print $$3}')
PUB2=$$(echo "$$OUT2" | grep "Public key:" | awk '{print $$3}')
echo "{\"id\": \"witness-2\", \"private_key\": \"$$PRIV2\", \"port\": 4002, \"network_id\": \"docker-net\", \"max_clock_skew\": 300}" > /data/witness2.json
# Generate witness-3
OUT3=$$(witness-node --generate-key)
PRIV3=$$(echo "$$OUT3" | grep "Private key:" | awk '{print $$3}')
PUB3=$$(echo "$$OUT3" | grep "Public key:" | awk '{print $$3}')
echo "{\"id\": \"witness-3\", \"private_key\": \"$$PRIV3\", \"port\": 4003, \"network_id\": \"docker-net\", \"max_clock_skew\": 300}" > /data/witness3.json
echo "📝 Creating network.json..."
cat > /data/network.json <<EOF
{
"id": "docker-net",
"threshold": 2,
"witnesses": [
{ "id": "witness-1", "pubkey": "$$PUB1", "endpoint": "http://witness-1:4001" },
{ "id": "witness-2", "pubkey": "$$PUB2", "endpoint": "http://witness-2:4002" },
{ "id": "witness-3", "pubkey": "$$PUB3", "endpoint": "http://witness-3:4003" }
],
"federation_peers": [],
"external_anchors": { "enabled": false, "providers": [] }
}
EOF
echo "✅ Setup complete."
witness-1:
build:
context: https://github.com/flammafex/witness.git
target: witness-node
depends_on:
witness-setup:
condition: service_completed_successfully
volumes:
- witness-config:/data
command: ["witness-node", "--config", "/data/witness1.json"]
witness-2:
build:
context: https://github.com/flammafex/witness.git
target: witness-node
depends_on:
witness-setup:
condition: service_completed_successfully
volumes:
- witness-config:/data
command: ["witness-node", "--config", "/data/witness2.json"]
witness-3:
build:
context: https://github.com/flammafex/witness.git
target: witness-node
depends_on:
witness-setup:
condition: service_completed_successfully
volumes:
- witness-config:/data
command: ["witness-node", "--config", "/data/witness3.json"]
witness-gateway:
build:
context: https://github.com/flammafex/witness.git
target: witness-gateway
ports:
- "8080:8080"
depends_on:
witness-setup:
condition: service_completed_successfully
witness-1:
condition: service_started
witness-2:
condition: service_started
witness-3:
condition: service_started
volumes:
- witness-config:/config
environment:
- RUST_LOG=info
command: ["witness-gateway", "--config", "/config/network.json", "--database", ":memory:"]
# ============================================================================
# HYPERTOKEN RELAY
# ============================================================================
hypertoken-relay:
build:
context: https://github.com/flammafex/hypertoken.git
command: ["node", "start-relay.js", "3000"]
ports:
- "3002:3000" # Moved to 3002 to avoid conflict with Web Wallet
volumes:
witness-config:
scarcity-data: # Persistence for wallets and explorer DB