Deploying Next.js to Alibaba Cloud FC 3.0 - A Practical Guide
Schwarz
Article
Deploying Next.js to Alibaba Cloud FC 3.0 - A Practical Guide
Deploying Next.js to Alibaba Cloud FC 3.0
A complete guide using sesefg (Next.js 16) as an example, covering the full workflow from local development to FC 3.0 deployment, including pitfalls and optimizations.
📋 Overview
Deploying a Next.js 16 (App Router + Standalone) project to Alibaba Cloud Function Compute FC 3.0 with custom domain.
Result:
- Website: https://www.yuntun-bj.com
- ISR Revalidation: POST /api/revalidate
Tech Stack:
- Next.js 16 — App Router, output: 'standalone'
- Docker — Containerized deployment
- Alibaba Cloud FC 3.0 — Serverless runtime
- Docker Hub — Image registry
🏗️ Project Structure
sesefg/
├── src/
│ ├── app/ # Next.js App Router pages
│ ├── components/ # React components
│ ├── lib/ # Utilities (API, i18n, SEO)
│ └── types/ # TypeScript types
├── Dockerfile # Production (local build version)
├── Dockerfile.fc # Full container build (alternative)
├── next.config.ts
└── package.json
Key next.config.ts settings:
const nextConfig: NextConfig = {
output: 'standalone',
images: {
formats: ['image/avif', 'image/webp'],
remotePatterns: [{ protocol: 'https', hostname: '**' }],
},
}
🚧 Pitfalls & Solutions
1. Docker Image Architecture Mismatch
Mac M-series (arm64) builds arm64 images by default, but FC instances are amd64, causing exec format error.
Fix: docker buildx build --platform linux/amd64
2. Native Modules Cross-Architecture
@swc and other native modules don't work cross-architecture.
Recommended: Local pnpm build, then Dockerfile only does COPY — 30 seconds.
Alternative: Full build inside amd64 container — about 4 minutes.
3. FC Function Name vs Domain Binding
s CLI created function web, but the custom domain was bound to sesefg.
Debug: aliyun fc-open GET /2021-04-06/custom-domains
4. ISR Not Persistent on FC
ISR cache is lost when FC instances are recycled. Use Revalidate API or accept fresh SSR.
✅ Correct Deployment Flow
Step 1: Build locally pnpm build
Step 2: Build & push image docker buildx build --platform linux/amd64 -t alichs/sesefg:latest --push .
Step 3: Get digest DIGEST=$(docker buildx imagetools inspect alichs/sesefg:latest | grep Digest | awk '{print $2}')
Step 4: Update FC function
aliyun fc UpdateFunction --region ap-northeast-1 \
--functionName sesefg \
--body '{"customContainerConfig":{"image":"docker.io/alichs/sesefg@DIGEST","port":3000}}'
Step 5: Verify curl -sL -o /dev/null -w '%{http_code}' https://www.yuntun-bj.com/
🔄 Daily Update
Code changes: build → push → update FC
Content changes: Just call Revalidate API, no redeployment needed.
💰 Cost
1 CPU / 2048MB RAM / Cold start ~10-20s / Warm ~1-3s / Monthly estimate < ¥20
🔑 Key Decisions
- FC 3.0: Supports Docker Hub, no ACR needed
- Region: ap-northeast-1 (Tokyo)
- Local build + COPY (30s vs 4min in-container)
- Docker Hub (free)
Generated: 2026-05-04 | Maintainer: Schwarz