feat(frontend): add Helm chart browser, monitoring, chart-references and values templates pages
Add new frontend pages for the multi-tenant OCDP platform: - Charts page (/charts): Browse Harbor OCI registries to list Helm chart repositories and versions, with deploy modal to launch charts on selected clusters - Monitoring page (/monitoring): Display cluster metrics (CPU/Memory/GPU usage) and per-node details with resource utilization bars - Chart References page (/chart-references): CRUD for chart metadata references - Values Templates page (/templates): CRUD for Helm values templates with version history and rollback support - Sidebar: Add Charts navigation, update Storage and Templates links - api.ts: Add all API client functions (clusterApi, registryApi, instanceApi, monitoringApi, storageApi, chartReferenceApi, valuesTemplateApi, workspaceApi, userApi) with full TypeScript types Note: deploy flow and values template rollback not yet end-to-end tested.
This commit is contained in:
218
Makefile
218
Makefile
@ -1,56 +1,192 @@
|
||||
# ============================================================
|
||||
# OCDP stack orchestration Makefile
|
||||
# run-2: 构建前端静态资源 + 启动 nginx(统一入口)和 backend 栈
|
||||
# clean-2: 清理 run-2 产生的容器 / 卷 / 网络
|
||||
# OCDP - Open Cloud Development Platform
|
||||
# Makefile for Docker Compose deployment
|
||||
# ============================================================
|
||||
|
||||
SHELL := /bin/bash
|
||||
|
||||
COMPOSE_BIN ?= docker compose
|
||||
# ============================================================
|
||||
# Configuration - Modify these for your environment
|
||||
# ============================================================
|
||||
|
||||
ROOT_COMPOSE := docker-compose.yml
|
||||
BACKEND_COMPOSE := backend/docker-compose.yml
|
||||
BACKEND_PROFILE := backend
|
||||
# Server IP for external access (客户端访问IP)
|
||||
SERVER_IP ?= 10.6.80.114
|
||||
|
||||
COMPOSE_STACK := $(COMPOSE_BIN) -f $(ROOT_COMPOSE) -f $(BACKEND_COMPOSE) --profile $(BACKEND_PROFILE)
|
||||
COMPOSE_STACK_ALL := $(COMPOSE_BIN) -f $(ROOT_COMPOSE) -f $(BACKEND_COMPOSE)
|
||||
STACK_ENV := ADAPTER_MODE=production BACKEND_BUILD_CONTEXT=$(abspath backend) BACKEND_BUILD_DOCKERFILE=$(abspath backend/Dockerfile) BACKEND_MOCK_BUILD_DOCKERFILE=$(abspath backend/Dockerfile.mock) INIT_DB_SQL_PATH=$(abspath backend/scripts/init-db.sql)
|
||||
# Backend configuration
|
||||
BACKEND_PORT ?= 8080
|
||||
JWT_SECRET ?= change-me-in-production
|
||||
ENCRYPTION_KEY ?= change-me-32-bytes-long-key-here
|
||||
DATABASE_URL ?= postgresql://postgres:postgres@postgres:5432/ocdp?sslmode=disable
|
||||
ADAPTER_MODE ?= production
|
||||
|
||||
STACK_SERVICES := postgres backend nginx
|
||||
# Allowed CORS origins (for external access)
|
||||
# 格式: http://IP:端口,多个用逗号分隔
|
||||
ALLOWED_ORIGINS ?= http://$(SERVER_IP),http://$(SERVER_IP):3000
|
||||
|
||||
.PHONY: run-2 clean-2 build-backend
|
||||
# Compose files
|
||||
COMPOSE_FILES := -f docker-compose.yml -f backend/docker-compose.yml
|
||||
|
||||
run-2:
|
||||
@echo "═══════════════════════════════════════════════"
|
||||
@echo "🚀 run-2: rebuild static assets + start web gateway stack"
|
||||
@echo "═══════════════════════════════════════════════"
|
||||
# Database init SQL path (relative to project root)
|
||||
INIT_DB_SQL_PATH ?= ./backend/scripts/init-db.sql
|
||||
|
||||
# ============================================================
|
||||
# Production Commands (Docker Compose)
|
||||
# ============================================================
|
||||
|
||||
.PHONY: up down restart clean logs logs-backend logs-frontend status help
|
||||
|
||||
# Start all services
|
||||
up:
|
||||
@echo "============================================"
|
||||
@echo "Starting OCDP services..."
|
||||
@echo "Server IP: $(SERVER_IP)"
|
||||
@echo "============================================"
|
||||
@ALLOWED_DEV_ORIGINS="$(ALLOWED_ORIGINS)" \
|
||||
DATABASE_URL="$(DATABASE_URL)" \
|
||||
JWT_SECRET="$(JWT_SECRET)" \
|
||||
ENCRYPTION_KEY="$(ENCRYPTION_KEY)" \
|
||||
ADAPTER_MODE="$(ADAPTER_MODE)" \
|
||||
BACKEND_PORT=$(BACKEND_PORT) \
|
||||
INIT_DB_SQL_PATH="$(INIT_DB_SQL_PATH)" \
|
||||
docker compose $(COMPOSE_FILES) --profile backend up -d
|
||||
@echo ""
|
||||
@export COMPOSE_PROJECT_NAME=ocdp && \
|
||||
export ADAPTER_MODE=production && \
|
||||
export BACKEND_BUILD_CONTEXT=$(abspath backend) && \
|
||||
export BACKEND_BUILD_DOCKERFILE=$(abspath backend/Dockerfile) && \
|
||||
export BACKEND_MOCK_BUILD_DOCKERFILE=$(abspath backend/Dockerfile.mock) && \
|
||||
export INIT_DB_SQL_PATH=$(abspath backend/scripts/init-db.sql) && \
|
||||
echo "→ Rebuilding frontend static assets" && \
|
||||
$(COMPOSE_STACK) run --rm frontend-build && \
|
||||
echo "" && \
|
||||
echo "→ Rebuilding backend image" && \
|
||||
$(COMPOSE_STACK) build backend && \
|
||||
echo "" && \
|
||||
echo "→ Bringing up backend + nginx services" && \
|
||||
$(COMPOSE_STACK) up -d $(STACK_SERVICES)
|
||||
@echo "✅ Services started:"
|
||||
@echo " Frontend: http://$(SERVER_IP)"
|
||||
@echo " Backend: http://$(SERVER_IP):$(BACKEND_PORT)/api/v1"
|
||||
@echo " Swagger: http://$(SERVER_IP):$(BACKEND_PORT)/api/docs"
|
||||
@echo " PostgreSQL: localhost:5432"
|
||||
@echo ""
|
||||
@echo "✅ Services online:"
|
||||
@echo "═══════════════════════════════════════════════"
|
||||
@echo " Default login: admin / admin123"
|
||||
@echo "============================================"
|
||||
|
||||
clean-2:
|
||||
@echo "═══════════════════════════════════════════════"
|
||||
@echo "🧹 clean-2: tearing down run-2 stack"
|
||||
@echo "═══════════════════════════════════════════════"
|
||||
@$(COMPOSE_STACK_ALL) down --remove-orphans || true
|
||||
@$(COMPOSE_STACK_ALL) down -v --remove-orphans || true
|
||||
@$(COMPOSE_BIN) -f $(BACKEND_COMPOSE) down -v --remove-orphans || true
|
||||
@echo "✅ Environment cleaned"
|
||||
@echo "═══════════════════════════════════════════════"
|
||||
# Stop all services (保留数据)
|
||||
down:
|
||||
@echo "Stopping OCDP services..."
|
||||
@docker compose $(COMPOSE_FILES) down
|
||||
|
||||
# Restart all services
|
||||
restart: down up
|
||||
|
||||
# Full cleanup (删除所有数据卷)
|
||||
clean:
|
||||
@echo "============================================"
|
||||
@echo "⚠️ Full cleanup - 警告:此操作将删除所有数据!"
|
||||
@echo "============================================"
|
||||
@docker compose $(COMPOSE_FILES) down -v
|
||||
@echo "✅ All services stopped and data removed"
|
||||
|
||||
# ============================================================
|
||||
# Build Commands
|
||||
# ============================================================
|
||||
|
||||
.PHONY: build build-frontend build-backend rebuild
|
||||
|
||||
# Build all images
|
||||
build:
|
||||
@docker compose $(COMPOSE_FILES) build
|
||||
|
||||
# Rebuild and start (强制重建前端)
|
||||
rebuild:
|
||||
@docker compose $(COMPOSE_FILES) up -d --build --force-recreate
|
||||
|
||||
# Rebuild frontend only
|
||||
build-frontend:
|
||||
@docker compose -f docker-compose.yml build frontend
|
||||
|
||||
# Rebuild backend only
|
||||
build-backend:
|
||||
@docker compose -f backend/docker-compose.yml build backend
|
||||
|
||||
# ============================================================
|
||||
# Log Commands
|
||||
# ============================================================
|
||||
|
||||
# View all logs
|
||||
logs:
|
||||
@docker compose $(COMPOSE_FILES) logs -f
|
||||
|
||||
# View backend logs
|
||||
logs-backend:
|
||||
@docker logs -f ocdp-backend
|
||||
|
||||
# View frontend logs
|
||||
logs-frontend:
|
||||
@docker logs -f ocdp-frontend
|
||||
|
||||
# View nginx logs
|
||||
logs-nginx:
|
||||
@docker logs -f ocdp-nginx
|
||||
|
||||
# ============================================================
|
||||
# Status Commands
|
||||
# ============================================================
|
||||
|
||||
# Show service status
|
||||
status:
|
||||
@docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
|
||||
|
||||
# ============================================================
|
||||
# Database Commands
|
||||
# ============================================================
|
||||
|
||||
.PHONY: db-reset db-init db-shell
|
||||
|
||||
# Reset database (删除并重建)
|
||||
db-reset:
|
||||
@echo "Resetting database..."
|
||||
@docker compose $(COMPOSE_FILES) exec -T postgres psql -U postgres -c "DROP DATABASE IF EXISTS ocdp;" || true
|
||||
@docker compose $(COMPOSE_FILES) exec -T postgres psql -U postgres -c "CREATE DATABASE ocdp;" || true
|
||||
@docker compose $(COMPOSE_FILES) exec -T postgres psql -U postgres -d ocdp -c "$$(cat backend/scripts/init-db.sql)"
|
||||
|
||||
# Initialize database
|
||||
db-init:
|
||||
@docker compose $(COMPOSE_FILES) exec -T postgres psql -U postgres -d ocdp -c "$$(cat backend/scripts/init-db.sql)"
|
||||
|
||||
# Open database shell
|
||||
db-shell:
|
||||
@docker compose $(COMPOSE_FILES) exec postgres psql -U postgres -d ocdp
|
||||
|
||||
# ============================================================
|
||||
# Help
|
||||
# ============================================================
|
||||
|
||||
help:
|
||||
@echo "OCDP - Open Cloud Deployment Platform"
|
||||
@echo ""
|
||||
@echo "Usage: make [target]"
|
||||
@echo ""
|
||||
@echo "Main Commands:"
|
||||
@echo " make up - 启动所有服务"
|
||||
@echo " make down - 停止所有服务(保留数据)"
|
||||
@echo " make restart - 重启所有服务"
|
||||
@echo " make clean - 完全清理(删除所有数据)"
|
||||
@echo " make rebuild - 强制重建并启动"
|
||||
@echo ""
|
||||
@echo "Build Commands:"
|
||||
@echo " make build - 构建所有镜像"
|
||||
@echo " make build-frontend - 只构建前端"
|
||||
@echo " make build-backend - 只构建后端"
|
||||
@echo ""
|
||||
@echo "Log Commands:"
|
||||
@echo " make logs - 查看所有日志"
|
||||
@echo " make logs-backend - 只看后端日志"
|
||||
@echo " make logs-frontend - 只看前端日志"
|
||||
@echo " make logs-nginx - 只看nginx日志"
|
||||
@echo ""
|
||||
@echo "Database Commands:"
|
||||
@echo " make db-reset - 重置数据库"
|
||||
@echo " make db-init - 初始化数据库"
|
||||
@echo " make db-shell - 进入数据库终端"
|
||||
@echo ""
|
||||
@echo "Utility Commands:"
|
||||
@echo " make status - 查看服务状态"
|
||||
@echo ""
|
||||
@echo "Environment Variables:"
|
||||
@echo " SERVER_IP=$(SERVER_IP) - 服务器IP(默认: 10.6.80.114)"
|
||||
@echo " BACKEND_PORT=$(BACKEND_PORT) - 后端端口(默认: 8080)"
|
||||
@echo " ALLOWED_ORIGINS=$(ALLOWED_ORIGINS) - 允许的跨域来源"
|
||||
@echo ""
|
||||
@echo "Examples:"
|
||||
@echo " make up SERVER_IP=192.168.1.100 # 自定义IP启动"
|
||||
@echo " make clean # 完全清理并重新开始"
|
||||
@echo "============================================"
|
||||
Reference in New Issue
Block a user