From 9254a200de574576abb4d6da690a8eb0967194d4 Mon Sep 17 00:00:00 2001 From: Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> Date: Sat, 11 Oct 2025 22:29:13 +0800 Subject: [PATCH] update docker compose generator to align current impl --- scripts/generate_docker_compose.py | 67 +++++++++++++++++++----------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/scripts/generate_docker_compose.py b/scripts/generate_docker_compose.py index 7176fd3..956f97d 100644 --- a/scripts/generate_docker_compose.py +++ b/scripts/generate_docker_compose.py @@ -70,7 +70,7 @@ def generate_postgres_service(config: dict) -> str: - POSTGRES_PASSWORD={config['postgres_password']} - POSTGRES_DB={config['postgres_db']} ports: - - "25432:5432" + - "25432:5432" # Optional: for external access volumes: - ./hub-meta/postgres-data:/var/lib/postgresql/data """ @@ -188,7 +188,7 @@ def generate_lakefs_service(config: dict) -> str: - LAKEFS_LOGGING_FORMAT=text - LAKEFS_LISTEN_ADDRESS=0.0.0.0:28000 ports: - - "28000:28000" # lakeFS Web + API + - "28000:28000" # LakeFS admin UI (optional) user: "${{UID}}:${{GID}}" {depends_on_str} volumes: {volumes_config} @@ -241,26 +241,47 @@ def generate_hub_api_service(config: dict) -> str: container_name: hub-api restart: always ports: - - "48888:48888" + - "48888:48888" # Internal API port (optional, for debugging) {depends_on_str} environment: - ## S3 Configuration - - KOHAKU_HUB_S3_PUBLIC_ENDPOINT={s3_endpoint_public} + ## ===== CRITICAL: Endpoint Configuration (MUST CHANGE) ===== + ## These determine how users access your KohakuHub instance + - KOHAKU_HUB_BASE_URL=http://127.0.0.1:28080 # Change to your public URL (e.g., https://hub.example.com) + - KOHAKU_HUB_S3_PUBLIC_ENDPOINT={s3_endpoint_public} # Change to your S3 public URL + + ## ===== CRITICAL: Security Configuration (MUST CHANGE) ===== + - KOHAKU_HUB_SESSION_SECRET={config['session_secret']} + - KOHAKU_HUB_ADMIN_SECRET_TOKEN={config['admin_secret']} + + ## ===== Performance Configuration ===== + - KOHAKU_HUB_WORKERS=4 # Number of worker processes (1-8, recommend: CPU cores) + + ## ===== Database Configuration ===== + - KOHAKU_HUB_DB_BACKEND=postgres + - KOHAKU_HUB_DATABASE_URL={db_url} + + ## ===== S3 Storage Configuration ===== - KOHAKU_HUB_S3_ENDPOINT={s3_endpoint_internal} - KOHAKU_HUB_S3_ACCESS_KEY={config['s3_access_key']} - KOHAKU_HUB_S3_SECRET_KEY={config['s3_secret_key']} -{s3_region_env} - KOHAKU_HUB_S3_BUCKET=hub-storage - ## LakeFS Configuration + - KOHAKU_HUB_S3_BUCKET=hub-storage + + ## ===== LakeFS Configuration ===== - KOHAKU_HUB_LAKEFS_ENDPOINT=http://lakefs:28000 - KOHAKU_HUB_LAKEFS_REPO_NAMESPACE=hf - ## Application Configuration - - KOHAKU_HUB_BASE_URL=http://127.0.0.1:28080 - - KOHAKU_HUB_DB_BACKEND=postgres - - KOHAKU_HUB_DATABASE_URL={db_url} + # LakeFS credentials auto-generated on first start + + ## ===== Application Configuration ===== + - KOHAKU_HUB_SITE_NAME=KohakuHub - KOHAKU_HUB_LFS_THRESHOLD_BYTES=1000000 - KOHAKU_HUB_LFS_KEEP_VERSIONS=5 - KOHAKU_HUB_LFS_AUTO_GC=true - - KOHAKU_HUB_SITE_NAME=KohakuHub - ## SMTP Configuration (Email Verification - Optional) + + ## ===== Auth & SMTP Configuration ===== + - KOHAKU_HUB_REQUIRE_EMAIL_VERIFICATION=false + - KOHAKU_HUB_SESSION_EXPIRE_HOURS=168 + - KOHAKU_HUB_TOKEN_EXPIRE_DAYS=365 + - KOHAKU_HUB_ADMIN_ENABLED=true + # SMTP (Optional - for email verification) - KOHAKU_HUB_SMTP_ENABLED=false - KOHAKU_HUB_SMTP_HOST=smtp.gmail.com - KOHAKU_HUB_SMTP_PORT=587 @@ -268,15 +289,8 @@ def generate_hub_api_service(config: dict) -> str: - KOHAKU_HUB_SMTP_PASSWORD= - KOHAKU_HUB_SMTP_FROM=noreply@kohakuhub.local - KOHAKU_HUB_SMTP_TLS=true - ## Auth Configuration - - KOHAKU_HUB_REQUIRE_EMAIL_VERIFICATION=false - - KOHAKU_HUB_SESSION_SECRET={config['session_secret']} - - KOHAKU_HUB_SESSION_EXPIRE_HOURS=168 - - KOHAKU_HUB_TOKEN_EXPIRE_DAYS=365 - ## Admin API Configuration - - KOHAKU_HUB_ADMIN_ENABLED=true - - KOHAKU_HUB_ADMIN_SECRET_TOKEN={config['admin_secret']} - ## Storage Quota Configuration + + ## ===== Storage Quota Configuration (Optional) ===== - KOHAKU_HUB_DEFAULT_USER_PRIVATE_QUOTA_BYTES=10_000_000 - KOHAKU_HUB_DEFAULT_USER_PUBLIC_QUOTA_BYTES=100_000_000 - KOHAKU_HUB_DEFAULT_ORG_PRIVATE_QUOTA_BYTES=10_000_000 @@ -293,7 +307,7 @@ def generate_hub_ui_service() -> str: container_name: hub-ui restart: always ports: - - "28080:80" + - "28080:80" # Public web interface volumes: - ./src/kohaku-hub-ui/dist:/usr/share/nginx/html - ./src/kohaku-hub-admin/dist:/usr/share/nginx/html-admin @@ -319,7 +333,12 @@ def generate_docker_compose(config: dict) -> str: if config["postgres_builtin"]: services.append(generate_postgres_service(config)) - content = "# docker-compose.yml\n# Generated by KohakuHub docker-compose generator\n\nservices:\n" + content = """# docker-compose.yml - KohakuHub Configuration +# Generated by KohakuHub docker-compose generator +# Customize for your deployment + +services: +""" content += "\n".join(services) # Network configuration