- Instance deployment: charts browser, deploy modal, instances list - Values Template version management (create/history/rollback) - Storage layered config (cluster > workspace > shared priority) - Cluster credential decryptIfNeeded for mixed encrypted/plaintext kubeconfig - YAML syntax validation (client-side + server-side warning) - Frontend: charts, instances, storage, templates, admin pages - Backend: storage service, instance service, cluster service, helm client - Multi-Tenant Kubeconfig.md: added by user
183 lines
6.3 KiB
YAML
183 lines
6.3 KiB
YAML
# ==================================================
|
|
# OCDP Backend - Docker Compose 统一配置
|
|
# ==================================================
|
|
# 使用方式:
|
|
#
|
|
# 1. 只启动依赖服务 (PostgreSQL) - 开发模式
|
|
# docker compose up -d
|
|
# 然后在本地运行: go run cmd/api/main.go
|
|
#
|
|
# 2. 启动完整服务 (PostgreSQL + Backend)
|
|
# docker compose --profile backend up -d
|
|
#
|
|
# 3. 启动 Mock 模式 (无需数据库)
|
|
# docker compose --profile mock up -d
|
|
#
|
|
# 4. 启动数据库管理工具 (可选)
|
|
# docker compose --profile tools up -d
|
|
#
|
|
# 停止服务:
|
|
# docker compose down
|
|
#
|
|
# 查看日志:
|
|
# docker compose logs -f
|
|
# ==================================================
|
|
|
|
services:
|
|
# ==================================================
|
|
# PostgreSQL 数据库 (默认启动)
|
|
# ==================================================
|
|
postgres:
|
|
image: postgres:17-alpine
|
|
container_name: ocdp-postgres
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_DB: ${POSTGRES_DB:-ocdp}
|
|
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
|
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --lc-collate=C --lc-ctype=C"
|
|
ports:
|
|
- "${POSTGRES_PORT:-5432}:5432"
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ${INIT_DB_SQL_PATH:-./scripts/init-db.sql}:/docker-entrypoint-initdb.d/01-init.sql:ro
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-ocdp}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 10s
|
|
networks:
|
|
- ocdp-network
|
|
|
|
# ==================================================
|
|
# Backend - 真实模式 (连接 PostgreSQL)
|
|
# 使用: docker compose --profile backend up -d
|
|
# ==================================================
|
|
backend:
|
|
build:
|
|
context: ${BACKEND_BUILD_CONTEXT:-.}
|
|
dockerfile: ${BACKEND_BUILD_DOCKERFILE:-Dockerfile}
|
|
image: ocdp-backend:latest
|
|
container_name: ocdp-backend
|
|
restart: unless-stopped
|
|
env_file:
|
|
- /media/ivanwu/DATA/ocdp-go/.env
|
|
environment:
|
|
ADAPTER_MODE: ${ADAPTER_MODE:-production}
|
|
PORT: 8080
|
|
JWT_SECRET: ${JWT_SECRET:-change-me-in-production}
|
|
ENCRYPTION_KEY: ${ENCRYPTION_KEY:-change-me-32-bytes-long-key-here}
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-ocdp}?sslmode=disable
|
|
KUBECONFIG: ""
|
|
ALLOWED_DEV_ORIGINS: ${ALLOWED_DEV_ORIGINS:-*}
|
|
# Bootstrap data (loaded from .env via env_file above)
|
|
BOOTSTRAP_ADMIN_USER: ${BOOTSTRAP_ADMIN_USER:-}
|
|
BOOTSTRAP_ADMIN_PASS: ${BOOTSTRAP_ADMIN_PASS:-}
|
|
BOOTSTRAP_ADMIN_EMAIL: ${BOOTSTRAP_ADMIN_EMAIL:-}
|
|
BOOTSTRAP_REGISTRY_NAME: ${BOOTSTRAP_REGISTRY_NAME:-}
|
|
BOOTSTRAP_REGISTRY_URL: ${BOOTSTRAP_REGISTRY_URL:-}
|
|
BOOTSTRAP_REGISTRY_DESC: ${BOOTSTRAP_REGISTRY_DESC:-}
|
|
BOOTSTRAP_REGISTRY_USER: ${BOOTSTRAP_REGISTRY_USER:-}
|
|
BOOTSTRAP_REGISTRY_PASS: ${BOOTSTRAP_REGISTRY_PASS:-}
|
|
BOOTSTRAP_REGISTRY_INSECURE: ${BOOTSTRAP_REGISTRY_INSECURE:-}
|
|
BOOTSTRAP_CLUSTERS: ${BOOTSTRAP_CLUSTERS:-}
|
|
BOOTSTRAP_CLUSTER_CLUSTER1_HOST: ${BOOTSTRAP_CLUSTER_CLUSTER1_HOST:-}
|
|
BOOTSTRAP_CLUSTER_CLUSTER1_DESC: ${BOOTSTRAP_CLUSTER_CLUSTER1_DESC:-}
|
|
BOOTSTRAP_CLUSTER_CLUSTER1_CA: ${BOOTSTRAP_CLUSTER_CLUSTER1_CA:-}
|
|
BOOTSTRAP_CLUSTER_CLUSTER1_CERT: ${BOOTSTRAP_CLUSTER_CLUSTER1_CERT:-}
|
|
BOOTSTRAP_CLUSTER_CLUSTER1_KEY: ${BOOTSTRAP_CLUSTER_CLUSTER1_KEY:-}
|
|
BOOTSTRAP_CLUSTER_CLUSTER2_HOST: ${BOOTSTRAP_CLUSTER_CLUSTER2_HOST:-}
|
|
BOOTSTRAP_CLUSTER_CLUSTER2_DESC: ${BOOTSTRAP_CLUSTER_CLUSTER2_DESC:-}
|
|
BOOTSTRAP_CLUSTER_CLUSTER2_CA: ${BOOTSTRAP_CLUSTER_CLUSTER2_CA:-}
|
|
BOOTSTRAP_CLUSTER_CLUSTER2_CERT: ${BOOTSTRAP_CLUSTER_CLUSTER2_CERT:-}
|
|
BOOTSTRAP_CLUSTER_CLUSTER2_KEY: ${BOOTSTRAP_CLUSTER_CLUSTER2_KEY:-}
|
|
ports:
|
|
- "${BACKEND_PORT:-8080}:8080"
|
|
volumes:
|
|
- ./config:/app/config:ro
|
|
- ./data:/app/data
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 15s
|
|
networks:
|
|
- ocdp-network
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
profiles:
|
|
- backend
|
|
|
|
# ==================================================
|
|
# Backend - Mock 模式 (无需数据库,适合快速测试)
|
|
# 使用: docker compose --profile mock up -d
|
|
# ==================================================
|
|
backend-mock:
|
|
build:
|
|
context: ${BACKEND_BUILD_CONTEXT:-.}
|
|
dockerfile: ${BACKEND_MOCK_BUILD_DOCKERFILE:-Dockerfile.mock}
|
|
container_name: ocdp-backend-mock
|
|
restart: unless-stopped
|
|
environment:
|
|
ADAPTER_MODE: mock
|
|
PORT: 8080
|
|
JWT_SECRET: ${JWT_SECRET:-test-jwt-secret-key}
|
|
ENCRYPTION_KEY: ${ENCRYPTION_KEY:-test-encryption-key-32-bytes-long}
|
|
ports:
|
|
- "${BACKEND_PORT:-8080}:8080"
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 5s
|
|
networks:
|
|
- ocdp-network
|
|
profiles:
|
|
- mock
|
|
|
|
# ==================================================
|
|
# pgAdmin - 数据库管理界面 (可选)
|
|
# 使用: docker compose --profile tools up -d
|
|
# ==================================================
|
|
pgadmin:
|
|
image: dpage/pgadmin4:latest
|
|
container_name: ocdp-pgadmin
|
|
restart: unless-stopped
|
|
environment:
|
|
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL:-admin@ocdp.local}
|
|
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD:-admin}
|
|
PGADMIN_CONFIG_SERVER_MODE: "False"
|
|
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "False"
|
|
ports:
|
|
- "${PGADMIN_PORT:-5050}:80"
|
|
volumes:
|
|
- pgadmin_data:/var/lib/pgadmin
|
|
networks:
|
|
- ocdp-network
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
profiles:
|
|
- tools
|
|
|
|
# ==================================================
|
|
# 网络配置
|
|
# ==================================================
|
|
networks:
|
|
ocdp-network:
|
|
driver: bridge
|
|
name: ocdp-network
|
|
|
|
# ==================================================
|
|
# 数据卷配置
|
|
# ==================================================
|
|
volumes:
|
|
postgres_data:
|
|
name: ocdp-postgres-data
|
|
pgadmin_data:
|
|
name: ocdp-pgadmin-data
|