From 695930016570de854eeab95677b2fafb03d3dfa9 Mon Sep 17 00:00:00 2001 From: "benjamin.747" Date: Thu, 29 Jan 2026 10:08:00 +0800 Subject: [PATCH] fix: update demo script --- .github/workflows/web-deploy.yml | 76 ++++++++++++++----------- docker/demo/.env.example | 16 ++---- docker/demo/docker-compose.demo.yml | 48 ++++++++++------ moon/apps/web/next.config.js | 4 ++ scripts/demo/build-demo-images-local.sh | 8 ++- 5 files changed, 92 insertions(+), 60 deletions(-) mode change 100644 => 100755 scripts/demo/build-demo-images-local.sh diff --git a/.github/workflows/web-deploy.yml b/.github/workflows/web-deploy.yml index 36063839f..6d4b14158 100644 --- a/.github/workflows/web-deploy.yml +++ b/.github/workflows/web-deploy.yml @@ -4,9 +4,9 @@ on: branches: - main paths: - - '.github/workflows/web-deploy.yml' - - 'moon/apps/web/**' - - 'moon/packages/**' + - ".github/workflows/web-deploy.yml" + - "moon/apps/web/**" + - "moon/packages/**" env: TIPTAP_PRIVATE_REGISTRY_KEY: ${{ secrets.TIPTAP_PRIVATE_REGISTRY_KEY }} @@ -26,7 +26,6 @@ concurrency: jobs: build-push-single-arch: - if: ${{ github.repository == 'web3infra-foundation/mega' }} runs-on: ubuntu-latest strategy: matrix: @@ -43,7 +42,7 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: '20' + node-version: "20" - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 @@ -80,7 +79,6 @@ jobs: manifest: needs: build-push-single-arch runs-on: ubuntu-latest - if: ${{ github.repository == 'web3infra-foundation/mega' }} strategy: matrix: env_name: [demo, staging, openatom, gitmono] @@ -104,32 +102,46 @@ jobs: env: REGISTRY: ${{ steps.login-ecr-public.outputs.registry }} run: | + set -euo pipefail + IMAGE_BASE="$REGISTRY/${{ env.REGISTRY_ALIAS }}/${{ env.REPOSITORY }}" - docker manifest create "$IMAGE_BASE:mega-ui-${{ matrix.env_name }}-0.1.0-pre-release" \ - "$IMAGE_BASE:mega-ui-${{ matrix.env_name }}-0.1.0-pre-release-amd64" \ - "$IMAGE_BASE:mega-ui-${{ matrix.env_name }}-0.1.0-pre-release-arm64" - docker manifest push "$IMAGE_BASE:mega-ui-${{ matrix.env_name }}-0.1.0-pre-release" + TAG="mega-ui-${{ matrix.env_name }}-0.1.0-pre-release" + + if [ "${{ matrix.env_name }}" = "demo" ]; then + echo "Creating multi-arch manifest for demo (amd64 + arm64)" + + docker manifest create "$IMAGE_BASE:$TAG" \ + "$IMAGE_BASE:${TAG}-amd64" \ + "$IMAGE_BASE:${TAG}-arm64" + else + echo "Creating amd64-only manifest for ${{ matrix.env_name }}" + + docker manifest create "$IMAGE_BASE:$TAG" \ + "$IMAGE_BASE:${TAG}-amd64" + fi + + docker manifest push "$IMAGE_BASE:$TAG" deploy: - needs: manifest - runs-on: ubuntu-latest - permissions: - contents: read - strategy: - matrix: - include: - - cluster: gitmega-com - service: mega-frontend-development-service-6dcihwup - - cluster: gitmono-com-mega-app - service: mega-ui-service - steps: - - name: Force ECS redeploy - run: | - aws ecs update-service \ - --cluster ${{ matrix.cluster }} \ - --service ${{ matrix.service }} \ - --force-new-deployment - env: - AWS_REGION: ap-southeast-2 - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + needs: manifest + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + matrix: + include: + - cluster: gitmega-com + service: mega-frontend-development-service-6dcihwup + - cluster: gitmono-com-mega-app + service: mega-ui-service + steps: + - name: Force ECS redeploy + run: | + aws ecs update-service \ + --cluster ${{ matrix.cluster }} \ + --service ${{ matrix.service }} \ + --force-new-deployment + env: + AWS_REGION: ap-southeast-2 + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/docker/demo/.env.example b/docker/demo/.env.example index a9f1c4159..3e791145a 100644 --- a/docker/demo/.env.example +++ b/docker/demo/.env.example @@ -27,7 +27,7 @@ POSTGRES_DB_MONO=mono # Note: For demo purposes, using root user only. For production, create dedicated user. MYSQL_ROOT_PASSWORD=mysqladmin -MYSQL_DATABASE=campsite +MYSQL_DATABASE=campsite_api_demo # ---------------------------------------------------------------------------- # RustFS (S3-compatible Object Storage) Configuration @@ -66,9 +66,9 @@ MEGA_DATABASE__DB_URL=postgres://postgres:postgres@postgres:5432/mono MEGA_REDIS__URL=redis://redis:6379 MEGA_MONOREPO__STORAGE_TYPE=s3compatible -OBJECT_STORAGE_S3__ENDPOINT_URL=http://rustfs:9000 -OBJECT_STORAGE_S3__BUCKET=mega -OBJECT_STORAGE_S3__REGION=us-east-1 +MEGA_OBJECT_STORAGE__S3__ENDPOINT_URL=http://rustfs:9000 +MEGA_OBJECT_STORAGE__S3__BUCKET=mega +MEGA_OBJECT_STORAGE__S3__REGION=us-east-1 MEGA_LOG__LEVEL=info MEGA_LOG__PRINT_STD=true @@ -88,13 +88,6 @@ MEGA_OAUTH__ALLOWED_CORS_ORIGINS=["http://app.gitmono.local:3000"] MEGA_BASE_DIR=/opt/mega MEGA_CACHE_DIR=/opt/mega/cache -# ---------------------------------------------------------------------------- -# Mega UI (Frontend) Configuration -# ---------------------------------------------------------------------------- - -MEGA_INTERNAL_HOST=http://mega:8000 -MEGA_HOST=http://git.gitmono.local:8000 -# NEXT_PUBLIC_ORION_API_URL=http://orion.gitmono.local:8004 # ---------------------------------------------------------------------------- # Orion Server Configuration @@ -125,6 +118,7 @@ RUST_LOG=info # Campsite API Configuration # ---------------------------------------------------------------------------- +CAMPSITE_REDIS_URL=redis://redis:6379 CAMPSITE_RAILS_ENV=demo CAMPSITE_SERVER_COMMAND=bundle exec puma CAMPSITE_DEV_APP_URL=http://app.gitmono.local:3000 diff --git a/docker/demo/docker-compose.demo.yml b/docker/demo/docker-compose.demo.yml index 1facecd3c..d397791cf 100644 --- a/docker/demo/docker-compose.demo.yml +++ b/docker/demo/docker-compose.demo.yml @@ -49,6 +49,8 @@ services: mysql: image: mysql:8.0 container_name: mega-demo-mysql + command: + - --default-authentication-plugin=mysql_native_password environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-mysqladmin} MYSQL_DATABASE: ${MYSQL_DATABASE:-campsite_api_demo} @@ -57,7 +59,11 @@ services: ports: - "3306:3306" healthcheck: - test: ["CMD-SHELL", "mysqladmin ping -h localhost -u root -p${MYSQL_ROOT_PASSWORD:-mysqladmin} || exit 1"] + test: + [ + "CMD-SHELL", + "mysqladmin ping -h localhost -u root -p${MYSQL_ROOT_PASSWORD:-mysqladmin} || exit 1", + ] interval: 5s timeout: 5s retries: 5 @@ -67,7 +73,7 @@ services: # Core Infra: RustFS (S3-compatible object storage) # --------------------------------------------------------------------------- rustfs: - image: rustfs/rustfs:latest + image: rustfs/rustfs:1.0.0-alpha.81 container_name: mega-demo-rustfs # Use 0.0.0.0:9000 to listen on both IPv4 and IPv6 for Docker network compatibility # Note: RUSTFS_SERVER_DOMAINS is not set to avoid virtual-host style conflicts @@ -98,7 +104,7 @@ services: # Use pre-built image from ECR Public: public.ecr.aws/m8q5m4u3/mega:mono-0.1.0-pre-release # Or use locally built image: mega:mono-engine-latest (after building with docker build) # Set MEGA_ENGINE_IMAGE environment variable to override - # Priority: MEGA_ENGINE_IMAGE env var > local build (mega:mono-engine-latest) > ECR image + # Priority: MEGA_ENGINE_IMAGE env var > local build (mega:mono-engine-latest) > ECR image mega: image: ${MEGA_ENGINE_IMAGE:-public.ecr.aws/m8q5m4u3/mega:mono-0.1.0-pre-release} container_name: mega-demo-backend @@ -120,13 +126,13 @@ services: # S3 / RustFS # To use S3 storage, set MEGA_MONOREPO__STORAGE_TYPE=s3 and ensure RustFS bucket is created MEGA_MONOREPO__STORAGE_TYPE: ${MEGA_MONOREPO__STORAGE_TYPE:-s3} - OBJECT_STORAGE_S3__ENDPOINT_URL: ${OBJECT_STORAGE_S3__ENDPOINT_URL:-http://rustfs:9000} + MEGA_OBJECT_STORAGE__S3__ENDPOINT_URL: ${MEGA_OBJECT_STORAGE__S3__ENDPOINT_URL:-http://rustfs:9000} # RustFS requires bucket names to follow S3 naming rules: 3-63 chars, lowercase, alphanumeric, hyphens - OBJECT_STORAGE_S3__BUCKET: ${OBJECT_STORAGE_S3__BUCKET:-mega} - OBJECT_STORAGE_S3__REGION: ${OBJECT_STORAGE_S3__REGION:-us-east-1} - OBJECT_STORAGE_S3__ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-rustfsadmin} - OBJECT_STORAGE_S3__SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-rustfsadmin} + MEGA_OBJECT_STORAGE__S3__BUCKET: ${MEGA_OBJECT_STORAGE__S3__BUCKET:-mega} + MEGA_OBJECT_STORAGE__S3__REGION: ${MEGA_OBJECT_STORAGE__S3__REGION:-us-east-1} + MEGA_OBJECT__S3__ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-rustfsadmin} + MEGA_OBJECT__S3__SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-rustfsadmin} # Force path-style addressing for RustFS (required for local S3-compatible storage) OBJECT_STORAGE_S3__FORCE_PATH_STYLE: ${OBJECT_STORAGE_S3__FORCE_PATH_STYLE:-true} @@ -170,6 +176,10 @@ services: timeout: 5s retries: 10 restart: unless-stopped + networks: + default: + aliases: + - git.gitmono.local # --------------------------------------------------------------------------- # Mega UI (Next.js) @@ -186,12 +196,6 @@ services: condition: service_healthy orion_server: condition: service_healthy - environment: - PORT: 3000 - # Ensure Next.js listens on all interfaces (0.0.0.0) for healthcheck to work - HOSTNAME: 0.0.0.0 - MEGA_INTERNAL_HOST: ${MEGA_INTERNAL_HOST:-http://mega:8000} - MEGA_HOST: ${MEGA_HOST:-http://localhost:8000} ports: # Container listens on 3000, host port is 3000 - "3000:3000" @@ -203,6 +207,10 @@ services: timeout: 5s retries: 10 restart: unless-stopped + networks: + default: + aliases: + - app.gitmono.local # --------------------------------------------------------------------------- # Orion Server (Rust) @@ -240,6 +248,10 @@ services: timeout: 5s retries: 10 restart: unless-stopped + networks: + default: + aliases: + - orion.gitmono.local # --------------------------------------------------------------------------- # Orion Build Client / Worker (based on orion-client image) @@ -284,6 +296,7 @@ services: redis: condition: service_healthy environment: + REDIS_URL: ${CAMPSITE_REDIS_URL:-redis://redis:6379} PORT: 8080 # Allow toggling migrations from .env CAMPSITE_RUN_MIGRATIONS: ${CAMPSITE_RUN_MIGRATIONS:-1} @@ -293,6 +306,11 @@ services: RAILS_MASTER_KEY: ${CAMPSITE_RAILS_MASTER_KEY:-51d8cdb046869075795ba82cdd95807a} SERVER_COMMAND: ${CAMPSITE_SERVER_COMMAND:-bundle exec puma} DEV_APP_URL: ${CAMPSITE_DEV_APP_URL:-http://localhost:3000} + networks: + default: + aliases: + - auth.gitmono.local + - api.gitmono.local command: - /bin/bash @@ -338,5 +356,3 @@ volumes: orion-logs: orion-worker-scorpio-data: orion-worker-workspace: - - diff --git a/moon/apps/web/next.config.js b/moon/apps/web/next.config.js index 7712d7a08..ee2846713 100644 --- a/moon/apps/web/next.config.js +++ b/moon/apps/web/next.config.js @@ -43,6 +43,10 @@ const cspResourcesByDirective = { // gitmono environments 'https://*.gitmono.com', 'wss://*.gitmono.com', + // Local demo environments + 'http://*.gitmono.local:8004', + 'http://*.gitmono.local:8000', + 'http://*.gitmono.local:8080', // Local development environments 'http://*.gitmono.test:3001', 'http://*.gitmono.test:8000', diff --git a/scripts/demo/build-demo-images-local.sh b/scripts/demo/build-demo-images-local.sh old mode 100644 new mode 100755 index e97251bdc..1f61a9909 --- a/scripts/demo/build-demo-images-local.sh +++ b/scripts/demo/build-demo-images-local.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail # ============================================================================ @@ -336,6 +336,10 @@ build_and_push() { # This guarantees the pushed artifact is a single-architecture image manifest. build_args+=(--load) + if [ "$image_name" = "mega-ui" ]; then + build_args+=(--build-arg APP_ENV=demo) + fi + # Add cache arguments build_args+=("${cache_from_args[@]}") @@ -345,6 +349,8 @@ build_and_push() { # Add build context build_args+=("${build_context}") + log_info "output build args: ${build_args[*]}" + # Build (load into local engine) if ! docker buildx build "${build_args[@]}"; then log_error "Failed to build ${image_name}"