Commit 838d0c64 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

docs: 将 JS9 标记为可选组件并更新构建说明

parent d7b9614b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ make ansible-update
- `csst-airflow`
- `csst-airflow-api-gateway`
- `csst-airflow-task-portal`
- `csst-airflow-js9`
- `csst-airflow-js9`(可选)

常用命令(在仓库根目录执行即可):

+33 −20
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
IMAGE_TAG ?= latest
BUILD_NUMBER ?= $(IMAGE_TAG)
HARBOR_PROJECT ?= 
SKIP_JS9 ?= 1

# 第三方依赖镜像清单文件
REQ_FILE := required-images.txt
@@ -13,6 +14,11 @@ TARGET_API_GATEWAY := $(HARBOR_PROJECT)csst-airflow-api-gateway:$(IMAGE_TAG)
TARGET_TASK_PORTAL := $(HARBOR_PROJECT)csst-airflow-task-portal:$(IMAGE_TAG)
TARGET_JS9 := $(HARBOR_PROJECT)csst-airflow-js9:$(IMAGE_TAG)

CUSTOM_IMAGE_COUNT := 4
ifeq ($(strip $(SKIP_JS9)),1)
CUSTOM_IMAGE_COUNT := 3
endif

ANSIBLE_EXTRA_VARS := -e env=$(ENV) -e image_tag=$(IMAGE_TAG)
ifneq ($(strip $(HARBOR_PROJECT)),)
ANSIBLE_EXTRA_VARS += -e harbor_project=$(HARBOR_PROJECT)
@@ -28,7 +34,8 @@ help:
	@echo "  make build       - Pull, retag third-party images, and build custom images"
	@echo "  make push	- Push all prepared images to the specified Harbor registry"
	@echo "  make clean       - Remove all custom built images (Airflow, API Gateway, Portal)"
	@echo "  make viewer-test - Build and run js9-service locally with ../data mounted"
	@echo "  make build SKIP_JS9=0 - Build with JS9 image (optional)"
	@echo "  make viewer-test - Build and run js9-service locally with ../data mounted (optional)"
	@echo "  make all	 - Execute clean, pull, build, and push sequentially"
	@echo "  make ansible-deploy - Deploy to environment (e.g. make ansible-deploy ENV=p368)"
	@echo "  make ansible-update - Update environment (e.g. make ansible-update ENV=p368)"
@@ -38,7 +45,7 @@ help:
	@echo ""
	@echo "Images to be processed:"
	@echo "  Third-party: postgres, redis, elasticsearch, kibana, filebeat, prometheus, grafana, cadvisor, node-exporter"
	@echo "  Custom:      csst-airflow, csst-airflow-api-gateway, csst-airflow-task-portal, csst-airflow-js9"
	@echo "  Custom:      csst-airflow, csst-airflow-api-gateway, csst-airflow-task-portal (and optional csst-airflow-js9)"
	@echo "======================================================================"

list-envs:
@@ -49,21 +56,22 @@ build:
	@echo "Checking external sources (../external):";
	if [ -d "../external/csst-dfs-client" ]; then echo "  [OK]   csst-dfs-client (api-gateway)"; else echo "  [MISS] csst-dfs-client (api-gateway)"; fi;
	if [ -d "../external/ccds" ]; then echo "  [OK]   ccds (api-gateway)"; else echo "  [MISS] ccds (api-gateway)"; fi;
	if [ -d "../external/js9" ]; then echo "  [OK]   js9 (js9 image)"; else echo "  [MISS] js9 (js9 image)"; fi;
	if [ "$(SKIP_JS9)" = "1" ]; then echo "  [SKIP] js9 (js9 image)"; else if [ -d "../external/js9" ]; then echo "  [OK]   js9 (js9 image)"; else echo "  [MISS] js9 (js9 image)"; fi; fi;
	if [ -d "../external/csst-dag" ]; then echo "  [OK]   csst-dag"; else echo "  [MISS] csst-dag"; fi;
	if [ -d "../external/csst-dags" ]; then echo "  [OK]   csst-dags"; else echo "  [MISS] csst-dags"; fi;
	@if [ ! -f $(REQ_FILE) ]; then echo "Error: $(REQ_FILE) not found"; exit 1; fi
	@total=$$(grep -v '^#' $(REQ_FILE) | grep -v '^$$' | wc -l); \
	echo "Pulling, retagging and building all $$(($$total+4)) images..."; \
	total_imgs=$$(($$total+$(CUSTOM_IMAGE_COUNT))); \
	echo "Pulling, retagging and building all $${total_imgs} images..."; \
	count=1; \
	for img in $$(grep -v '^#' $(REQ_FILE) | grep -v '^$$'); do \
		basename="$${img##*/}"; \
		name="$${basename%%:*}"; \
		target="$(HARBOR_PROJECT)$${name}:$(IMAGE_TAG)"; \
		if docker image inspect $${img} > /dev/null 2>&1; then \
			echo "[$${count}/$$(($$total+4))] Processing $${img} -> $${target} (Skipping pull, already exists)..."; \
			echo "[$${count}/$${total_imgs}] Processing $${img} -> $${target} (Skipping pull, already exists)..."; \
		else \
			echo "[$${count}/$$(($$total+4))] Processing $${img} -> $${target}..."; \
			echo "[$${count}/$${total_imgs}] Processing $${img} -> $${target}..."; \
			(docker pull $${img} > /dev/null 2>&1 || true); \
		fi; \
		if [ "$${img}" != "$${target}" ]; then \
@@ -71,9 +79,9 @@ build:
		fi; \
		count=$$((count+1)); \
	done; \
	echo "[$$(($$total+1))/$$(($$total+4))] Building Airflow Custom Image ($(TARGET_AIRFLOW))..."; \
	echo "[$$(($$total+1))/$${total_imgs}] Building Airflow Custom Image ($(TARGET_AIRFLOW))..."; \
	docker build -q -t $(TARGET_AIRFLOW) .; \
	echo "[$$(($$total+2))/$$(($$total+4))] Building API Gateway Image ($(TARGET_API_GATEWAY))..."; \
	echo "[$$(($$total+2))/$${total_imgs}] Building API Gateway Image ($(TARGET_API_GATEWAY))..."; \
		if [ -d "../external/csst-dfs-client" ]; then \
				mkdir -p ./api_gateway/csst-dfs-client; \
				rsync -a --delete --exclude ".git" --exclude "__pycache__" ../external/csst-dfs-client/ ./api_gateway/csst-dfs-client/; \
@@ -85,35 +93,40 @@ build:
	docker build -q -t $(TARGET_API_GATEWAY) ./api_gateway; \
	rm -rf ./api_gateway/csst-dfs-client; \
	rm -rf ./api_gateway/ccds; \
	echo "[$$(($$total+3))/$$(($$total+4))] Building Task Portal Image ($(TARGET_TASK_PORTAL)) with BUILD_NUMBER=$(BUILD_NUMBER)..."; \
	echo "[$$(($$total+3))/$${total_imgs}] Building Task Portal Image ($(TARGET_TASK_PORTAL)) with BUILD_NUMBER=$(BUILD_NUMBER)..."; \
	docker build -q --build-arg VITE_BUILD_NUMBER=$(BUILD_NUMBER) --build-arg VITE_BUILD_TIME="$(shell date '+%Y-%m-%d %H:%M:%S')" -t $(TARGET_TASK_PORTAL) ./frontend_vue; \
	echo "[$$(($$total+4))/$$(($$total+4))] Building JS9 Image ($(TARGET_JS9))..."; \
	if [ "$(SKIP_JS9)" != "1" ]; then \
		echo "[$$(($$total+4))/$${total_imgs}] Building JS9 Image ($(TARGET_JS9))..."; \
		if [ -d "../external/js9" ]; then \
				mkdir -p ./external/js9; \
				rsync -a --delete --exclude ".git" --exclude "__pycache__" ../external/js9/ ./external/js9/; \
		fi; \
		docker build -q -t $(TARGET_JS9) -f ./js9_service/Dockerfile .; \
		rm -rf ./external/js9; \
	echo "All $$(($$total+4)) images prepared successfully."
	fi; \
	echo "All $${total_imgs} images prepared successfully."

push:
	@if [ -z "$(HARBOR_PROJECT)" ]; then echo "Error: HARBOR_PROJECT is empty. Please specify a registry prefix to push. Example: make push HARBOR_PROJECT=csu-harbor.csst.nao:10443/csst/"; exit 1; fi
	@total=$$(grep -v '^#' $(REQ_FILE) | grep -v '^$$' | wc -l); \
	echo "Pushing all $$(($$total+4)) images to $(HARBOR_PROJECT)..."; \
	total_imgs=$$(($$total+$(CUSTOM_IMAGE_COUNT))); \
	echo "Pushing all $${total_imgs} images to $(HARBOR_PROJECT)..."; \
	count=1; \
	for img in $$(grep -v '^#' $(REQ_FILE) | grep -v '^$$'); do \
		basename="$${img##*/}"; \
		name="$${basename%%:*}"; \
		target="$(HARBOR_PROJECT)$${name}:$(IMAGE_TAG)"; \
		echo "[$${count}/$$(($$total+4))] Pushing $${target}..."; \
		echo "[$${count}/$${total_imgs}] Pushing $${target}..."; \
		docker push $${target}; \
		count=$$((count+1)); \
	done; \
	echo "[$$(($$total+1))/$$(($$total+4))] Pushing $(TARGET_AIRFLOW)..." && docker push $(TARGET_AIRFLOW); \
	echo "[$$(($$total+2))/$$(($$total+4))] Pushing $(TARGET_API_GATEWAY)..." && docker push $(TARGET_API_GATEWAY); \
	echo "[$$(($$total+3))/$$(($$total+4))] Pushing $(TARGET_TASK_PORTAL)..." && docker push $(TARGET_TASK_PORTAL); \
	echo "[$$(($$total+4))/$$(($$total+4))] Pushing $(TARGET_JS9)..." && docker push $(TARGET_JS9); \
	echo "All $$(($$total+4)) images pushed successfully to $(HARBOR_PROJECT) with tag $(IMAGE_TAG)."
	echo "[$$(($$total+1))/$${total_imgs}] Pushing $(TARGET_AIRFLOW)..." && docker push $(TARGET_AIRFLOW); \
	echo "[$$(($$total+2))/$${total_imgs}] Pushing $(TARGET_API_GATEWAY)..." && docker push $(TARGET_API_GATEWAY); \
	echo "[$$(($$total+3))/$${total_imgs}] Pushing $(TARGET_TASK_PORTAL)..." && docker push $(TARGET_TASK_PORTAL); \
	if [ "$(SKIP_JS9)" != "1" ]; then \
		echo "[$$(($$total+4))/$${total_imgs}] Pushing $(TARGET_JS9)..." && docker push $(TARGET_JS9); \
	fi; \
	echo "All $${total_imgs} images pushed successfully to $(HARBOR_PROJECT) with tag $(IMAGE_TAG)."

all: clean pull build push