-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathMakefile
More file actions
573 lines (529 loc) · 22.6 KB
/
Copy pathMakefile
File metadata and controls
573 lines (529 loc) · 22.6 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
MAKEFLAGS += --no-print-directory
WITH_MINERU ?= false # 默认不构建mineru
VERSION ?= latest
NAMESPACE ?= datamate
# Registry configuration: use --dev for local images, otherwise use GitHub registry
ifdef dev
REGISTRY :=
else
REGISTRY ?= ghcr.io/modelengine-group/
endif
ifdef COMSPEC
# Windows
MAKE := "C:/Program Files (x86)/GnuWin32/bin/make"
else
# Linux/Mac
MAKE := make
endif
# ========== Help ==========
.PHONY: help
help:
@echo "DataMate Makefile - Available Commands"
@echo ""
@echo "Usage: make <target> [options]"
@echo ""
@echo "Options:"
@echo " dev=true Use local images instead of registry (empty REGISTRY)"
@echo " VERSION=<version> Set image version (default: latest)"
@echo " NAMESPACE=<name> Set Kubernetes namespace (default: datamate)"
@echo " INSTALLER=<type> Set installer type: docker or k8s"
@echo " PLATFORM=<platform> Set platform for downloads (default: linux/amd64)"
@echo " Options: linux/amd64, linux/arm64"
@echo " SAVE=true Save images to dist/ during download (default: false)"
@echo ""
@echo "Build Commands:"
@echo " make build Build all core images"
@echo " make <service>-docker-build Build specific service image"
@echo " Valid services: backend, database, frontend, runtime,"
@echo " backend-python, deer-flow, mineru"
@echo ""
@echo "Install Commands:"
@echo " make install Install datamate + milvus (prompts for method)"
@echo " make install INSTALLER=docker Install using Docker Compose"
@echo " make install INSTALLER=k8s Install using Kubernetes/Helm"
@echo " make install INSTALLER=k8s (requires Sealed Secrets Controller)"
@echo " make install-<component> Install specific component (prompts)"
@echo " make <component>-docker-install Install component via Docker"
@echo " make <component>-k8s-install Install component via Kubernetes"
@echo " Valid components: datamate, milvus, deer-flow, mineru"
@echo " Valid services: backend, frontend, runtime, label-studio"
@echo ""
@echo "Uninstall Commands:"
@echo " make uninstall Uninstall datamate + milvus (prompts)"
@echo " make uninstall INSTALLER=docker Uninstall using Docker Compose"
@echo " make uninstall INSTALLER=k8s Uninstall using Kubernetes/Helm"
@echo " make uninstall-<component> Uninstall specific component (prompts)"
@echo " make <component>-docker-uninstall Uninstall component via Docker"
@echo " make <component>-k8s-uninstall Uninstall component via Kubernetes"
@echo " Note: Docker uninstall will prompt whether to delete volumes"
@echo ""
@echo "Upgrade Commands:"
@echo " make datamate-docker-upgrade Upgrade datamate deployment"
@echo ""
@echo "Download Commands:"
@echo " make download Pull all images (no save by default)"
@echo " make download VERSION=<version> Pull all images with specific version"
@echo " make download REGISTRY=<registry> Pull images from specific registry"
@echo " make load-images Load all downloaded images from dist/"
@echo " make download-sealed-secrets Download Sealed Secrets image (for offline)"
@echo ""
@echo "Utility Commands:"
@echo " make create-namespace Create Kubernetes namespace"
@echo " make node-setup Configure dedicated nodes interactively"
@echo " make node-cleanup Remove node labels and taints"
@echo " make help Show this help message"
@echo ""
@echo "Examples:"
@echo " make build dev=true Build all images for local development"
@echo " make install INSTALLER=docker Install via Docker Compose"
@echo " make install dev=true Install using local images"
@echo " make datamate-docker-upgrade Upgrade running datamate services"
@echo ""
.DEFAULT_GOAL := help
# ========== Functions ==========
# Prompt user to choose installer if not specified
define prompt-installer
@echo "Choose a deployment method:"
@echo "1. Docker/Docker-Compose"
@echo "2. Kubernetes/Helm"
@echo -n "Enter choice: "
@read choice; \
case $$choice in \
1) INSTALLER=docker ;; \
2) INSTALLER=k8s ;; \
*) echo "Invalid choice" && exit 1 ;; \
esac; \
$(MAKE) $(1)
endef
# Prompt user to choose installer and volume deletion for uninstall
define prompt-uninstaller
@echo "Choose a deployment method:"
@echo "1. Docker/Docker-Compose"
@echo "2. Kubernetes/Helm"
@echo -n "Enter choice: "
@read installer_choice; \
case $$installer_choice in \
1) INSTALLER=docker ;; \
2) INSTALLER=k8s ;; \
*) echo "Invalid choice" && exit 1 ;; \
esac; \
if [ "$$INSTALLER" = "docker" ]; then \
echo "Delete volumes? (This will remove all data)"; \
echo "1. Yes - Delete volumes"; \
echo "2. No - Keep volumes"; \
echo -n "Enter choice (default: 2): "; \
read DELETE_VOLUMES_CHOICE; \
$(MAKE) $(1) DELETE_VOLUMES_CHOICE=$$DELETE_VOLUMES_CHOICE; \
else \
$(MAKE) $(1); \
fi
endef
# Generic docker build function
# Usage: $(call docker-build,service-name,image-name)
define docker-build
docker build -t $(2):$(VERSION) . -f scripts/images/$(1)/Dockerfile
endef
# Generic docker compose service action
# Usage: $(call docker-compose-service,service-name,action,compose-dir)
define docker-compose-service
cd $(3) && docker compose $(2) $(1)
endef
# Prompt user to choose whether to delete volumes
define prompt-volume-deletion
@echo "Delete volumes? (This will remove all data)"
@echo "1. Yes - Delete volumes"
@echo "2. No - Keep volumes"
@echo -n "Enter choice (default: 2): "
@read choice; \
case $$choice in \
1) echo "-v" ;; \
*) echo "" ;; \
esac
endef
# ========== Build Targets ==========
# Valid build targets
VALID_BUILD_TARGETS := frontend backend gateway database runtime backend-python deer-flow label-studio mineru mineru-910B mineru-910C mineru-310P
# Generic docker build target with service name as parameter
# Automatically prefixes image names with "datamate-" unless it's deer-flow
.PHONY: %-docker-build
%-docker-build:
@if ! echo " $(VALID_BUILD_TARGETS) " | grep -q " $* "; then \
echo "Error: Unknown build target '$*'"; \
echo "Valid build targets are:"; \
for target in $(VALID_BUILD_TARGETS); do \
echo " - $$target"; \
done; \
exit 1; \
fi
@if [ "$*" = "deer-flow" ]; then \
$(call docker-build,deer-flow-backend,deer-flow-backend); \
$(call docker-build,deer-flow-frontend,deer-flow-frontend); \
elif [ "$*" = "mineru" ] || [ "$*" = "mineru-910B" ]; then \
wget -qO - https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile | docker build --network=host -t datamate-mineru -f - .; \
elif [ "$*" = "mineru-910C" ]; then \
wget -qO - https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile | sed 's/v0.11.0/v0.11.0-a3/g' | docker build --network=host -t datamate-mineru -f - .; \
elif [ "$*" = "mineru-310P" ]; then \
wget -qO - https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile | sed 's/v0.11.0/v0.10.0rc1-310p/g' | docker build --network=host -t datamate-mineru -f - .; \
else \
$(call docker-build,$*,datamate-$*); \
fi
.PHONY: build-%
build-%: %-docker-build
@:
.PHONY: build
build: database-docker-build gateway-docker-build backend-docker-build frontend-docker-build runtime-docker-build backend-python-docker-build
# ========== Utility Targets ==========
.PHONY: create-namespace
create-namespace:
kubectl get namespace $(NAMESPACE) > /dev/null 2>&1 || kubectl create namespace $(NAMESPACE)
# ========== Node Setup/Cleanup Targets ==========
.PHONY: node-setup
node-setup:
@echo "Configure dedicated nodes for DataMate deployment?"
@echo "This will apply labels and optional taints to selected nodes."
@echo "1. Yes - Configure nodes interactively"
@echo "2. No - Use default scheduling"
@echo -n "Enter choice (default: 2): "
@read NODE_SETUP_CHOICE; \
if [ "$$NODE_SETUP_CHOICE" = "1" ]; then \
chmod +x scripts/k8s/node-setup.sh; \
./scripts/k8s/node-setup.sh --namespace $(NAMESPACE); \
fi
.PHONY: node-cleanup
node-cleanup:
@chmod +x scripts/k8s/node-cleanup.sh
@./scripts/k8s/node-cleanup.sh --namespace $(NAMESPACE)
# ========== Generic Install/Uninstall Targets (Redirect to prompt-installer) ==========
.PHONY: install-%
install-%:
ifeq ($(origin INSTALLER), undefined)
$(call prompt-installer,$*-$$INSTALLER-install)
else
$(MAKE) $*-$(INSTALLER)-install
endif
.PHONY: install
install:
ifeq ($(origin INSTALLER), undefined)
$(call prompt-installer,datamate-$$INSTALLER-install milvus-$$INSTALLER-install)
else
$(MAKE) datamate-$(INSTALLER)-install
$(MAKE) milvus-$(INSTALLER)-install
endif
.PHONY: uninstall-%
uninstall-%:
ifeq ($(origin INSTALLER), undefined)
$(call prompt-uninstaller,$*-$$INSTALLER-uninstall)
else
$(MAKE) $*-$(INSTALLER)-uninstall
endif
.PHONY: uninstall
uninstall:
ifeq ($(origin INSTALLER), undefined)
$(call prompt-uninstaller,label-studio-$$INSTALLER-uninstall milvus-$$INSTALLER-uninstall deer-flow-$$INSTALLER-uninstall datamate-$$INSTALLER-uninstall)
else
@if [ "$(INSTALLER)" = "docker" ]; then \
echo "Delete volumes? (This will remove all data)"; \
echo "1. Yes - Delete volumes"; \
echo "2. No - Keep volumes"; \
echo -n "Enter choice (default: 2): "; \
read DELETE_VOLUMES_CHOICE; \
export DELETE_VOLUMES_CHOICE; \
fi; \
$(MAKE) label-studio-$(INSTALLER)-uninstall DELETE_VOLUMES_CHOICE=$$DELETE_VOLUMES_CHOICE; \
$(MAKE) milvus-$(INSTALLER)-uninstall DELETE_VOLUMES_CHOICE=$$DELETE_VOLUMES_CHOICE; \
$(MAKE) deer-flow-$(INSTALLER)-uninstall DELETE_VOLUMES_CHOICE=$$DELETE_VOLUMES_CHOICE; \
$(MAKE) datamate-$(INSTALLER)-uninstall DELETE_VOLUMES_CHOICE=$$DELETE_VOLUMES_CHOICE
endif
# ========== Docker Install/Uninstall Targets ==========
# Valid service targets for docker install/uninstall
VALID_SERVICE_TARGETS := datamate backend frontend runtime backend-python database gateway redis deer-flow milvus label-studio data-juicer mineru mineru-910B mineru-910C mineru-310P
# Generic docker service install target
.PHONY: %-docker-install
%-docker-install:
@if ! echo " $(VALID_SERVICE_TARGETS) " | grep -q " $* "; then \
echo "Error: Unknown service target '$*'"; \
echo "Valid service targets are:"; \
for target in $(VALID_SERVICE_TARGETS); do \
echo " - $$target"; \
done; \
exit 1; \
fi
@if [ ! -f deployment/docker/datamate/.env ]; then \
echo "ERROR: deployment/docker/datamate/.env not found."; \
echo "Create it from the template:"; \
echo " cp deployment/docker/datamate/.env.example deployment/docker/datamate/.env"; \
echo "Then edit it with your actual passwords."; \
exit 1; \
fi
@if [ "$*" = "label-studio" ]; then \
REGISTRY=$(REGISTRY) docker compose -f deployment/docker/datamate/docker-compose.yml --profile label-studio up -d; \
elif [ "$*" = "datamate" ]; then \
REGISTRY=$(REGISTRY) docker compose -f deployment/docker/datamate/docker-compose.yml up -d; \
elif [ "$*" = "mineru" ] || [ "$*" = "mineru-910B" ] || [ "$*" = "mineru-910C" ]; then \
REGISTRY=$(REGISTRY) docker compose -f deployment/docker/datamate/docker-compose.yml --profile mineru up -d datamate-mineru; \
elif [ "$*" = "mineru-310P" ]; then \
REGISTRY=$(REGISTRY) EXTRA_ARGS="--enforce-eager --dtype float16" docker compose -f deployment/docker/datamate/docker-compose.yml --profile mineru up -d datamate-mineru; \
elif [ "$*" = "data-juicer" ]; then \
REGISTRY=$(REGISTRY) docker compose -f deployment/docker/datamate/docker-compose.yml --profile data-juicer up -d datamate-data-juicer; \
elif [ "$*" = "redis" ]; then \
REGISTRY=$(REGISTRY) docker compose -f deployment/docker/datamate/docker-compose.yml --profile redis up -d datamate-redis; \
elif [ "$*" = "milvus" ]; then \
REGISTRY=$(REGISTRY) docker compose -f deployment/docker/datamate/docker-compose.yml --profile milvus up -d; \
elif [ "$*" = "deer-flow" ]; then \
cp runtime/deer-flow/.env deployment/docker/datamate/.env; \
cp runtime/deer-flow/conf.yaml deployment/docker/datamate/conf.yaml; \
REGISTRY=$(REGISTRY) docker compose -f deployment/docker/datamate/docker-compose.yml --profile deer-flow up -d; \
else \
REGISTRY=$(REGISTRY) docker compose -f deployment/docker/datamate/docker-compose.yml up -d datamate-$*; \
fi
# Generic docker service uninstall target
.PHONY: %-docker-uninstall
%-docker-uninstall:
@if ! echo " $(VALID_SERVICE_TARGETS) " | grep -q " $* "; then \
echo "Error: Unknown service target '$*'"; \
echo "Valid service targets are:"; \
for target in $(VALID_SERVICE_TARGETS); do \
echo " - $$target"; \
done; \
exit 1; \
fi
@if [ "$*" = "label-studio" ]; then \
docker compose -f deployment/docker/datamate/docker-compose.yml rm -f -s label-studio; \
elif [ "$*" = "mineru" ] || [ "$*" = "mineru-910B" ] || [ "$*" = "mineru-910C" ] || [ "$*" = "mineru-310P" ]; then \
docker compose -f deployment/docker/datamate/docker-compose.yml rm -f -s datamate-mineru; \
elif [ "$*" = "data-juicer" ] || [ "$*" = "dj" ]; then \
docker compose -f deployment/docker/datamate/docker-compose.yml rm -f -s datamate-data-juicer; \
elif [ "$*" = "redis" ]; then \
docker compose -f deployment/docker/datamate/docker-compose.yml rm -f -s datamate-redis; \
elif [ "$*" = "datamate" ]; then \
if [ "$(DELETE_VOLUMES_CHOICE)" = "1" ]; then \
docker compose -f deployment/docker/datamate/docker-compose.yml --profile mineru --profile redis --profile data-juicer --profile deer-flow --profile label-studio --profile milvus down -v; \
else \
docker compose -f deployment/docker/datamate/docker-compose.yml --profile mineru --profile redis --profile data-juicer --profile deer-flow --profile label-studio --profile milvus down; \
fi; \
elif [ "$*" = "deer-flow" ]; then \
docker compose -f deployment/docker/datamate/docker-compose.yml rm -f -s deer-flow-backend deer-flow-frontend; \
elif [ "$*" = "milvus" ]; then \
docker compose -f deployment/docker/datamate/docker-compose.yml rm -f -s milvus etcd minio; \
else \
$(call docker-compose-service,$*,down,deployment/docker/datamate); \
fi
# ========== Kubernetes Install/Uninstall Targets ==========
# Valid k8s targets
VALID_K8S_TARGETS := datamate deer-flow milvus label-studio data-juicer mineru mineru-910B mineru-910C mineru-310P
# Generic k8s install target
.PHONY: %-k8s-install
%-k8s-install: create-namespace
@if ! echo " $(VALID_K8S_TARGETS) " | grep -q " $* "; then \
echo "Error: Unknown k8s target '$*'"; \
echo "Valid k8s targets are:"; \
for target in $(VALID_K8S_TARGETS); do \
echo " - $$target"; \
done; \
exit 1; \
fi
@if [ "$*" = "label-studio" ]; then \
kubectl apply -f deployment/kubernetes/sealed-secrets/label-studio.yaml; \
helm upgrade label-studio deployment/helm/label-studio/ -n $(NAMESPACE) --install; \
elif [ "$*" = "mineru" ] || [ "$*" = "mineru-910B" ] || [ "$*" = "mineru-910C" ]; then \
kubectl apply -f deployment/kubernetes/mineru/deploy-910.yaml -n $(NAMESPACE); \
elif [ "$*" = "mineru-310P" ]; then \
kubectl apply -f deployment/kubernetes/mineru/deploy-310.yaml -n $(NAMESPACE); \
elif [ "$*" = "datamate" ]; then \
echo ""; \
chmod +x scripts/k8s/node-setup.sh; \
./scripts/k8s/node-setup.sh --namespace $(NAMESPACE); \
if [ -f /tmp/datamate-helm-args.sh ]; then \
source /tmp/datamate-helm-args.sh; \
fi; \
kubectl apply -f deployment/kubernetes/sealed-secrets/datamate.yaml; \
if [ -n "$$HELM_NODE_SELECTOR_ARGS" ] || [ -n "$$$HELM_TOLERATIONS_ARGS" ]; then \
helm upgrade datamate deployment/helm/datamate/ -n $(NAMESPACE) --install --set global.image.repository=$(REGISTRY) --set public.secrets.create=false $$HELM_NODE_SELECTOR_ARGS $$HELM_TOLERATIONS_ARGS; \
else \
helm upgrade datamate deployment/helm/datamate/ -n $(NAMESPACE) --install --set global.image.repository=$(REGISTRY) --set public.secrets.create=false; \
fi; \
rm -f /tmp/datamate-helm-args.sh; \
elif [ "$*" = "deer-flow" ]; then \
cp runtime/deer-flow/.env deployment/helm/deer-flow/charts/public/.env; \
cp runtime/deer-flow/conf.yaml deployment/helm/deer-flow/charts/public/conf.yaml; \
helm upgrade deer-flow deployment/helm/deer-flow -n $(NAMESPACE) --install --set global.image.repository=$(REGISTRY); \
elif [ "$*" = "milvus" ]; then \
kubectl apply -f deployment/kubernetes/sealed-secrets/milvus.yaml 2>/dev/null || true; \
ACCESSKEY=$$(kubectl get secret milvus-minio-secret -n $(NAMESPACE) -o jsonpath='{.data.accessKey}' 2>/dev/null | base64 -d 2>/dev/null || echo ""); \
SECRETKEY=$$(kubectl get secret milvus-minio-secret -n $(NAMESPACE) -o jsonpath='{.data.secretKey}' 2>/dev/null | base64 -d 2>/dev/null || echo ""); \
if [ -n "$$ACCESSKEY" ] && [ -n "$$SECRETKEY" ]; then \
helm upgrade milvus deployment/helm/milvus -n $(NAMESPACE) --install \
--set minio.accessKey=$$ACCESSKEY \
--set minio.secretKey=$$SECRETKEY; \
else \
echo "[ERROR] milvus-minio-secret not found or empty in namespace $(NAMESPACE)"; \
echo " Please ensure Sealed Secrets Controller is running and the secret was decrypted."; \
echo " For local dev: kubectl create secret generic milvus-minio-secret \\"; \
echo " --from-literal=accessKey=<key> --from-literal=secretKey=<key> -n $(NAMESPACE)"; \
exit 1; \
fi; \
elif [ "$*" = "data-juicer" ] || [ "$*" = "dj" ]; then \
kubectl apply -f deployment/kubernetes/data-juicer/deploy.yaml -n $(NAMESPACE); \
fi
# Generic k8s uninstall target
.PHONY: %-k8s-uninstall
%-k8s-uninstall:
@if ! echo " $(VALID_K8S_TARGETS) " | grep -q " $* "; then \
echo "Error: Unknown k8s target '$*'"; \
echo "Valid k8s targets are:"; \
for target in $(VALID_K8S_TARGETS); do \
echo " - $$target"; \
done; \
exit 1; \
fi
@if [ "$*" = "mineru" ] || [ "$*" = "mineru-910B" ] || [ "$*" = "mineru-910C" ]; then \
kubectl delete -f deployment/kubernetes/mineru/deploy-910.yaml -n $(NAMESPACE); \
elif [ "$*" = "mineru-310P" ]; then \
kubectl delete -f deployment/kubernetes/mineru/deploy-310.yaml -n $(NAMESPACE); \
elif [ "$*" = "datamate" ]; then \
echo ""; \
echo "Remove node configuration (labels/taints)? (y/n) [n]"; \
read -p "> " CLEANUP_NODES; \
if [ "$$CLEANUP_NODES" = "y" ] || [ "$$CLEANUP_NODES" = "Y" ]; then \
$(MAKE) node-cleanup; \
fi; \
helm uninstall datamate -n $(NAMESPACE) --ignore-not-found; \
elif [ "$*" = "deer-flow" ]; then \
helm uninstall deer-flow -n $(NAMESPACE) --ignore-not-found; \
elif [ "$*" = "milvus" ]; then \
helm uninstall milvus -n $(NAMESPACE) --ignore-not-found; \
elif [ "$*" = "label-studio" ]; then \
helm uninstall label-studio -n $(NAMESPACE) --ignore-not-found; \
elif [ "$*" = "data-juicer" ] || [ "$*" = "dj" ]; then \
kubectl delete -f deployment/kubernetes/data-juicer/deploy.yaml -n $(NAMESPACE); \
fi
# ========== Download Targets ==========
# List of all images to download
DOWNLOAD_IMAGES := \
datamate-backend \
datamate-frontend \
datamate-database \
datamate-runtime \
datamate-backend-python \
datamate-gateway \
# Detect architecture for smart default
CURRENT_ARCH := $(shell uname -m 2>/dev/null)
ifeq ($(CURRENT_ARCH),aarch64)
DEFAULT_OPTION := 2
else ifeq ($(CURRENT_ARCH),arm64)
DEFAULT_OPTION := 2
else
DEFAULT_OPTION := 1
endif
#Usage: make download VERSION=1.0.0 REGISTRY=ghcr.io/modelengine-group/ SAVE=true
.PHONY: download
download:
@echo "Select target platform for images:"
@echo " 1) x86_64 (Intel/AMD, linux/amd64)"
@echo " 2) ARM64 (Apple Silicon, Raspberry Pi 4+, linux/arm64)"
@{ \
read -p "Enter choice [1/2] (default: $(DEFAULT_OPTION)): " plat_choice; \
case "$${plat_choice:-$(DEFAULT_OPTION)}" in \
1) PLATFORM="linux/amd64" ;; \
2) PLATFORM="linux/arm64" ;; \
*) echo "Invalid choice. Using default option $(DEFAULT_OPTION)."; \
PLATFORM=$$([ "$(DEFAULT_OPTION)" = "1" ] && echo "linux/amd64" || echo "linux/arm64");; \
esac; \
\
read -p "Save images to dist/ for offline use? (y/n): " save_resp; \
case "$$save_resp" in \
[yY]|[yY][eE][sS]) SAVE="true" ;; \
*) SAVE="false" ;; \
esac; \
\
if [ -z "$(REGISTRY)" ] && [ "$$SAVE" != "true" ]; then \
echo "Error: REGISTRY unset and SAVE=false. Nothing to do."; \
exit 1; \
fi; \
\
if [ "$$SAVE" = "true" ]; then mkdir -p dist; fi; \
failed=0; \
\
for image in $(DOWNLOAD_IMAGES); do \
if [ -z "$(REGISTRY)" ]; then \
src_image="$$image:$(VERSION)"; \
echo "Using local image: $$src_image"; \
else \
src_image="$(REGISTRY)$$image:$(VERSION)"; \
echo "Pulling $$src_image ($$PLATFORM)..."; \
if ! docker pull --platform "$$PLATFORM" "$$src_image"; then \
echo "✗ Failed to pull $$src_image"; \
failed=$$(($$failed + 1)); \
continue; \
fi; \
fi; \
\
if [ "$$SAVE" = "true" ]; then \
output="dist/$$image-$(VERSION).tar"; \
echo "Saving to $$output..."; \
if docker save -o "$$output" "$$src_image"; then \
echo "✓ Saved $$image"; \
else \
echo "✗ Failed to save $$src_image"; \
failed=$$(($$failed + 1)); \
fi; \
else \
echo "✓ Ready: $$src_image"; \
fi; \
echo ""; \
done; \
\
if [ $$failed -eq 0 ]; then \
if [ "$$SAVE" = "true" ]; then \
echo "✅ All images saved to dist/"; \
echo "Load on target: docker load -i <image>.tar"; \
else \
echo "✅ All images ready in local Docker daemon"; \
fi; \
else \
echo "❌ $$failed image(s) failed"; \
exit 1; \
fi; \
}
DEER_FLOW_IMAGES := \
deer-flow-backend \
deer-flow-frontend
.PHONY: download-deer-flow
download-deer-flow:
$(MAKE) download DOWNLOAD_IMAGES="$(DEER_FLOW_IMAGES)"
# Download Sealed Secrets controller image for offline/air-gapped environments
SEALED_SECRETS_IMAGE := bitnami/sealed-secrets-controller:latest
.PHONY: download-sealed-secrets
download-sealed-secrets:
@echo "Pulling Sealed Secrets controller image..."
@mkdir -p dist
docker pull $(SEALED_SECRETS_IMAGE)
docker save $(SEALED_SECRETS_IMAGE) -o dist/sealed-secrets-controller.tar
@echo "✅ Saved to dist/sealed-secrets-controller.tar"
@echo "Transfer to offline environment and load with: docker load -i dist/sealed-secrets-controller.tar"
# Load all downloaded images from dist/ directory
.PHONY: load-images
load-images:
@if [ ! -d "dist" ]; then \
echo "Error: dist/ directory not found"; \
echo "Please run 'make download' first to download images"; \
exit 1; \
fi
@echo "Loading images from dist/..."
@count=0; \
for tarfile in dist/*.tar.gz; do \
if [ -f "$$tarfile" ]; then \
echo "Loading $$tarfile..."; \
docker load -i "$$tarfile"; \
count=$$((count + 1)); \
echo "✓ Loaded $$tarfile"; \
echo ""; \
fi; \
done; \
if [ $$count -eq 0 ]; then \
echo "No image files found in dist/"; \
echo "Please run 'make download' first"; \
exit 1; \
else \
echo "Successfully loaded $$count image(s)"; \
fi