-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
190 lines (164 loc) · 6.17 KB
/
Makefile
File metadata and controls
190 lines (164 loc) · 6.17 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
# Bridge Ecosystem Makefile
.PHONY: help build push up down restart logs clean test dev mainnet testnet
# Default target
help:
@echo "Bridge Ecosystem Management"
@echo ""
@echo "Usage:"
@echo " make build - Build all Docker images locally"
@echo " make push - Push images to ghcr.io/luxfi"
@echo " make up - Start development server (requires ghcr.io images)"
@echo " make up-local - Start local infrastructure only (recommended)"
@echo " make dev - Alias for 'make up'"
@echo " make mainnet - Start mainnet deployment"
@echo " make testnet - Start testnet deployment"
@echo " make down - Stop the bridge ecosystem"
@echo " make down-local - Stop local infrastructure and MPC nodes"
@echo " make restart - Restart all services"
@echo " make logs - View logs for all services"
@echo " make clean - Clean up volumes and containers"
@echo " make test - Run tests"
@echo " make export-keys - Export MPC keys from running nodes"
@echo ""
@echo "For local development without Docker images:"
@echo " 1. make up-local # Start infrastructure"
@echo " 2. ./start-mpc-local.sh # Start MPC nodes"
@echo " 3. cd app/server && pnpm dev # Start server"
@echo " 4. cd app/bridge && pnpm dev # Start UI"
# Build all Docker images
build: build-mpc build-server build-ui
build-mpc:
@echo "Building MPC service..."
cd ../mpc && docker buildx build --platform linux/amd64,linux/arm64 \
-t ghcr.io/luxfi/lux-mpc:latest \
-f Dockerfile \
.
build-server:
@echo "Building Bridge server..."
docker buildx build --platform linux/amd64,linux/arm64 \
-t ghcr.io/luxfi/bridge-server:latest \
-f app/server/Dockerfile \
app/server/
build-ui:
@echo "Building Bridge UI..."
docker buildx build --platform linux/amd64,linux/arm64 \
-t ghcr.io/luxfi/bridge-ui:latest \
-f app/bridge/Dockerfile \
app/bridge/
# Push images to ghcr.io/luxfi
push: build
@echo "Pushing images to ghcr.io/luxfi..."
docker push ghcr.io/luxfi/lux-mpc:latest
docker push ghcr.io/luxfi/bridge-server:latest
docker push ghcr.io/luxfi/bridge-ui:latest
# Start local development server
up:
@echo "Starting local development infrastructure (KMS, Lux ID, databases)..."
@echo "Note: MPC nodes and app services should be run locally"
docker compose -f compose.local.yml up -d
@echo ""
@echo "Infrastructure started! Now run:"
@echo " 1. MPC nodes: cd ../mpc && make build && ./lux-mpc start"
@echo " 2. Bridge server: cd app/server && pnpm dev"
@echo " 3. Bridge UI: cd app/bridge && pnpm dev"
# Start local development with infrastructure only
up-local:
@echo "Starting local infrastructure services..."
docker compose -f compose-infra.yml up -d
@echo ""
@echo "Infrastructure started! Now run:"
@echo " 1. MPC nodes: make start-mpc-nodes"
@echo " 2. Bridge server: cd app/server && pnpm dev"
@echo " 3. Bridge UI: cd app/bridge && pnpm dev"
# Alias for up
dev: up
# Start mainnet deployment
mainnet:
@echo "Starting mainnet deployment..."
docker compose -f compose.mainnet.yml up -d
# Start testnet deployment
testnet:
@echo "Starting testnet deployment..."
docker compose -f compose.testnet.yml up -d
# Stop the bridge ecosystem
down:
@echo "Stopping bridge ecosystem..."
docker compose -f compose.local.yml down
# Stop local infrastructure
down-local:
@echo "Stopping local infrastructure..."
docker compose -f compose-infra.yml down
@echo "Stopping MPC nodes..."
make stop-mpc-nodes || true
# Restart all services
restart: down up
# View logs
logs:
docker compose logs -f
# Clean up
clean:
@echo "Cleaning up..."
docker compose down -v
docker system prune -f
# Run tests
test:
@echo "Running tests..."
cd app/server && pnpm test
cd mpc-service && go test ./...
# Install dependencies
install:
@echo "Installing dependencies..."
cd app/server && pnpm install
cd app/bridge && pnpm install
# Login to GitHub Container Registry
login:
@echo "Logging in to ghcr.io..."
docker login ghcr.io
# Export MPC keys from running nodes
export-keys:
@echo "Exporting MPC keys from running nodes..."
@echo "Creating exports directory..."
@mkdir -p exports/mpc-keys
@echo "Exporting from mpc-node-0..."
docker exec bridge-mpc-0 cat /data/mpc/keys/node_key.json > exports/mpc-keys/node-0-key.json || echo "Failed to export from node-0"
@echo "Exporting from mpc-node-1..."
docker exec bridge-mpc-1 cat /data/mpc/keys/node_key.json > exports/mpc-keys/node-1-key.json || echo "Failed to export from node-1"
@echo "Exporting from mpc-node-2..."
docker exec bridge-mpc-2 cat /data/mpc/keys/node_key.json > exports/mpc-keys/node-2-key.json || echo "Failed to export from node-2"
@echo "Keys exported to exports/mpc-keys/"
@echo "WARNING: These keys are sensitive. Store them securely!"
# Import MPC keys to new deployment
import-keys:
@echo "Importing MPC keys to nodes..."
@if [ ! -d "exports/mpc-keys" ]; then echo "No keys found in exports/mpc-keys/"; exit 1; fi
docker cp exports/mpc-keys/node-0-key.json bridge-mpc-0:/data/mpc/keys/node_key.json
docker cp exports/mpc-keys/node-1-key.json bridge-mpc-1:/data/mpc/keys/node_key.json
docker cp exports/mpc-keys/node-2-key.json bridge-mpc-2:/data/mpc/keys/node_key.json
@echo "Keys imported. Restart nodes to apply."
# Install MPC tools
install-mpc:
@echo "Installing MPC tools..."
@./scripts/install-mpc-tools.sh
# Start MPC nodes locally
start-mpc-nodes:
@echo "Starting MPC nodes locally..."
@./scripts/start-mpc-network.sh
# Stop MPC nodes
stop-mpc-nodes:
@echo "Stopping MPC nodes..."
@./scripts/stop-mpc-network.sh
# Initialize MPC keys
init-mpc:
@echo "Initializing MPC keys..."
cd ../mpc && ./lux-mpc-cli generate-peers --number 3 --output peers.json
cd ../mpc && ./scripts/setup_identities.sh
@echo "MPC keys initialized"
# Backup all data
backup:
@echo "Creating backup..."
@mkdir -p backups/$(shell date +%Y%m%d_%H%M%S)
docker exec bridge-postgres pg_dump -U bridge bridge > backups/$(shell date +%Y%m%d_%H%M%S)/postgres.sql
docker cp bridge-mpc-0:/data/mpc backups/$(shell date +%Y%m%d_%H%M%S)/mpc-0
docker cp bridge-mpc-1:/data/mpc backups/$(shell date +%Y%m%d_%H%M%S)/mpc-1
docker cp bridge-mpc-2:/data/mpc backups/$(shell date +%Y%m%d_%H%M%S)/mpc-2
@echo "Backup created in backups/"