Files
ocdp-go/Makefile
Ivan087 29d0310f03 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.
2026-04-15 16:59:31 +08:00

192 lines
6.3 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ============================================================
# OCDP - Open Cloud Development Platform
# Makefile for Docker Compose deployment
# ============================================================
SHELL := /bin/bash
# ============================================================
# Configuration - Modify these for your environment
# ============================================================
# Server IP for external access (客户端访问IP)
SERVER_IP ?= 10.6.80.114
# 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
# Allowed CORS origins (for external access)
# 格式: http://IP:端口,多个用逗号分隔
ALLOWED_ORIGINS ?= http://$(SERVER_IP),http://$(SERVER_IP):3000
# Compose files
COMPOSE_FILES := -f docker-compose.yml -f backend/docker-compose.yml
# 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 ""
@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 " Default login: admin / admin123"
@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 "============================================"