デプロイ

Docker ビルド

本プロジェクトでは node:22-alpine を使用した2段階の Docker ビルドを採用しています。

ステージ 1 --- ビルダー:

FROM node:22-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
ARG NEXT_PUBLIC_START_URL
ARG NEXT_PUBLIC_SIGNUP_URL
ARG NEXT_PUBLIC_SITE_URL
RUN npm run build

ステージ 2 --- ランナー:

FROM node:22-alpine
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
EXPOSE 3000
CMD ["node", "server.js"]

ビルドは Next.js の output: 'standalone' モードに依存しており、.next/standalone 内に自己完結型の server.js を生成します。最終イメージには node_modules は含まれません --- 必要な依存関係はすべて Next.js によって standalone 出力にバンドルされます。

Next.js のテレメトリは両方のステージで無効化されています。

NEXT_PUBLIC_* 環境変数は Docker の ARG 宣言を通じてビルド時にクライアントバンドルに埋め込まれます。--build-arg で渡してください。

イメージのビルド:

docker build -t flexgalaxy-www \
  --build-arg NEXT_PUBLIC_SITE_URL=https://flexgalaxy.ai \
  --build-arg NEXT_PUBLIC_START_URL=https://console.flexgalaxy.ai/start/ \
  --build-arg NEXT_PUBLIC_SIGNUP_URL="https://console.flexgalaxy.ai/start/?register=true" \
  .

コンテナの実行:

docker run -p 3000:3000 \
  -e STRAPI_URL=https://cms.flexgalaxy.ai \
  flexgalaxy-www

Next.js の設定

next.config.ts には2つの重要な設定が含まれています:

  • Sass: legacy-js-api の非推奨警告を抑制します。これは @carbon/styles の SCSS 互換性のために必要です

  • 画像: <Image>http://localhost:1337/uploads/**``(ローカル Strapi)から画像を読み込めるようにします。本番環境では、Strapi の本番ホスト名を ``remotePatterns に追加してください

next.config.ts には i18n 設定はありません --- ロケールルーティングはすべてミドルウェアで処理されます。

環境変数

変数

デフォルト

説明

STRAPI_URL

http://localhost:1337

Strapi CMS ベース URL

NEXT_PUBLIC_SITE_URL

http://localhost:3000

サイト公開 URL (SEO メタ)

NEXT_PUBLIC_START_URL

https://console.flexgalaxy.ai/start/

SSR fallback for Login button

NEXT_PUBLIC_SIGNUP_URL

https://console.flexgalaxy.ai/start/?register=true

SSR fallback for Sign Up CTA

NODE_ENV

デプロイ

Docker を使用せずに本番ビルドを行う場合:

NEXT_TELEMETRY_DISABLED

1 (in Docker)

Next.js テレメトリを無効化

NEXT_PUBLIC_* 変数は Next.js によりビルド時に埋め込まれます。Docker ビルドでは ARG / ENV ペアを通じて注入されます。ランタイムでは、サーバーサイド変数(STRAPI_URL)のみオーバーライド可能です。

注釈

Since March 2026, Login, Sign Up, and Admin URLs are derived at runtime from the browser hostname via useConsoleUrls() in src/lib/consoleUrl.ts. The NEXT_PUBLIC_START_URL and NEXT_PUBLIC_SIGNUP_URL variables now serve only as SSR fallbacks displayed during server-side rendering before client-side hydration computes the correct domain-specific URL.

This means a single Docker image works on both .ai (international) and .com (China) deployments without requiring a separate build per partition. See アーキテクチャ for details on the derivation logic.

本番ビルド

Docker を使用せずに本番ビルドを行う場合:

npm run build
npm start

build コマンドは .next/ に最適化された出力を生成します。start コマンドはポート 3000 で本番ビルドを配信します。

CI/CD

ドキュメントは deploy-docs.yml GitHub Actions ワークフローを通じてビルド・デプロイされます。共有の Makefile、ビルドスクリプト、Carbon テーマにアクセスするため、SiriusVoyager/infra-common をプロジェクトと一緒にチェックアウトします。

ドキュメントのビルドでは infra-common/docs/build-i18n.sh を使用します。このスクリプトは conf.py からプロジェクト名を読み取り、多言語 HTML 出力を生成します。

AWS インフラストラクチャ

www アプリケーションは DotID AWS アカウント内の DotID の EKS クラスター上にテナントとしてデプロイされます。Terraform 設定は terraform/ にあります。

Dual-partition deployment:

Partition

Domain

DNS Provider

AWS Region

International

flexgalaxy.ai

GoDaddy

ap-northeast-1

China

flexgalaxy.com

Aliyun (Alibaba Cloud)

cn-north-1

AWS accounts (China partition):

Account

AWS Account ID

Profile

Use

DotID CN

890180556369

fg-dotid-cn-prod

Keycloak, EKS cluster, www, OrbitCast

Infra CN

890176879308

fg-ai-cn-prod-deploy

NovaBell, api-gateway (SSO via cn-northwest-1)

IaC State CN

890078969307

iac-infrastructure

Terraform state (S3 + DynamoDB) only

AWS accounts (International partition):

Deploy with the deploy.sh script:

# International (prod)
./deploy.sh prod --partition intl

# China (prod)
./deploy.sh prod --partition cn

# Dev
./deploy.sh dev

DotID からの共有インフラストラクチャ(remote state 経由):

  • VPC、EKS クラスター(コンピューティング)

  • ACM wildcard certificate for TLS termination

www Terraform で管理:

  • www Docker イメージ用の ECR リポジトリ

  • Kubernetes 名前空間(www)、deployment、service、configmap

  • 共有 ACM 証明書による TLS 付き NLB(インターネット向け)

  • CloudFront CDN distribution (intl partition) for static asset caching

DNS is managed externally, NOT in AWS Route53:

  • flexgalaxy.ai --- GoDaddy (international partition)

  • flexgalaxy.com --- Aliyun / Alibaba Cloud DNS (China partition)

After terraform apply, create CNAME records manually in the respective DNS provider. Terraform outputs www_nlb_hostname and cdn_acm_validation_records to help with DNS setup.

CDN

International partition uses CloudFront (global) with managed cache policies and ACM certificates. Configuration is in cdn.tf, controlled by enable_cdn = true in prod-intl.tfvars.

China partition uses CloudFront China (*.cloudfront.cn), which has significant limitations compared to the global service:

  • aws_cloudfront_cache_policynot supported in China regions

  • aws_cloudfront_origin_request_policynot supported in China regions

  • ACM certificates — not supported for CloudFront China; must use IAM-uploaded server certificates instead

The current cdn.tf only supports the international partition. China partition CDN requires a separate implementation using legacy forwarded_values blocks and IAM certificate references.

Current production (legacy):

The existing www.flexgalaxy.com CDN is a CloudFront China distribution (d341g2nskxpja3.cloudfront.cn) managed in the fg-ai-ops account (148308503730). It was created by the old Terraform codebase and uses:

  • IAM certificate ASCASFB7AFSZC7VW5X6UC

  • Legacy ForwardedValues (forwards all cookies + query strings, no headers)

  • Single default cache behavior (no separate static asset caching)

  • HTTP/1.1 only, IPv6 disabled

  • Origin: NLB in cn-northwest-1, port 8080

CDN AWS account (China):

Account

AWS Account ID

Profile

Use

fg-ai-ops

148308503730

fg-ai-ops-cdn-deploy

CloudFront China distributions

This account is a member of the AWS CN organization (management account 633349536424 / sr-awscn-admin).

TODO: China CDN Migration

Migrate the CN partition CDN from the legacy setup to Terraform-managed configuration. This work should be done separately from the initial www CN deployment.

1. Make cdn.tf partition-aware:

  • Add is_china_partition variable (bool, default false)

  • CN mode: use forwarded_values blocks instead of cache/origin-request policy resources

  • CN mode: use var.cdn_iam_certificate_id instead of ACM

  • CN mode: use http2 (not http2and3)

  • CN mode: enable IPv6

  • Add separate /_next/static/* and /images/* cache behaviors with aggressive TTLs (missing from legacy config)

  • Add Accept-Language header forwarding in default behavior for i18n

2. Consolidate docs.flexgalaxy.com into www.flexgalaxy.com/docs/legacy:

The docs.flexgalaxy.com distribution (EXIZH9G3CAXFK in fg-ai-ops) currently serves:

  • Default: NLB port 8081 (main docs site)

  • /en-us/organization/latest/api/*: S3 origin fws-cn-api-reference-docs.s3.cn-northwest-1.amazonaws.com.cn (path: /fws-global-published/organization/website)

Migration steps:

  • Add S3 origin to the www distribution for /docs/legacy/* path

  • Add a Next.js rewrite rule or CloudFront behavior to route /docs/legacy/* to the S3 bucket

  • Verify content is accessible at new path

  • Disable and delete the docs.flexgalaxy.com distribution

  • Remove docs.flexgalaxy.com CNAME from Aliyun DNS

  • Add redirect from docs.flexgalaxy.comwww.flexgalaxy.com/docs/legacy during transition period

3. Deploy new CN CDN:

  • Set enable_cdn = true and is_china_partition = true in prod-cn.tfvars

  • Set cdn_iam_certificate_id = "ASCASFB7AFSZC7VW5X6UC" (reuse existing IAM cert, or upload a new one)

  • Deploy with ./deploy.sh prod --partition cn

  • Update www.flexgalaxy.com CNAME in Aliyun to point to the new distribution

  • Disable and delete the legacy distribution (E38L5N5NHTWU77)