Skip to content

feat: optimize Docker image size with three-image matrix - #506

Closed
cxhello wants to merge 12 commits into
nacos-group:masterfrom
cxhello:feat/docker-image-optimization
Closed

feat: optimize Docker image size with three-image matrix#506
cxhello wants to merge 12 commits into
nacos-group:masterfrom
cxhello:feat/docker-image-optimization

Conversation

@cxhello

@cxhello cxhello commented May 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Rewrite Dockerfile with multi-stage build: eclipse-temurin:17-jre (standard) + eclipse-temurin:17-jre-alpine (slim), removing bundled Python/AI dependencies
  • Add Dockerfile.AI layered on standard image for users who need AI features (skill scanner, MCP registry)
  • Overhaul CI: new ci.yml for PR validation (build test + size check + smoke test), rewritten build&push.yaml for three-image publish with upgraded Actions (v4/v6)

Image Size Impact

Image Before (v3.2.0) After Change
standard (v3.2.x) 1.26 GB ~300 MB -76%
slim (v3.2.x-slim) ≈1.26 GB ~250 MB -80%
ai (v3.2.x-ai) ~550 MB new

Breaking Changes

  • Users relying on AI features (skill scanner, MCP registry) with the default image must switch to the -ai tag
  • Dockerfile.Slim removed (slim is now a target in the main Dockerfile)

Other Changes

  • application.properties: AI pipeline hardcoded to false in standard/slim
  • application-ai.properties: new config with AI features enabled
  • docker-startup.sh: removed JDK 8 dead code (CMS GC, java.ext.dirs)
  • README.md: added image variants table and migration guide

Closes #505

cxhello added 12 commits May 26, 2026 14:09
AI features (ai-pipeline, skill-scanner, anonymous AI access) are now
hardcoded to false in the default application.properties. Users who need
AI features should use the -ai tagged image.

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
Separate config file with AI features enabled: ai-pipeline,
skill-scanner, anonymous AI access, and MCP registry default to true.

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
All Docker images now use JDK 17 exclusively. Remove version detection,
CMS GC parameters, java.ext.dirs, and legacy GC logging flags.

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
…gets

Replace the single-stage ubuntu+python Dockerfile with a multi-stage
build: downloader stage fetches nacos-server tarball, standard target
uses eclipse-temurin:17-jre (Ubuntu), slim target uses
eclipse-temurin:17-jre-alpine. Python, uv, cisco-ai-skill-scanner,
and AI data packages are removed from both targets.

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
Layered on top of the standard nacos/nacos-server image. Adds Python
3.10 via uv, cisco-ai-skill-scanner, AI data packages, and
application-ai.properties with AI features enabled.

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
Slim target is now a build stage in the main Dockerfile.
Dockerfile.Slim was identical to Dockerfile since PR nacos-group#495.

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
New ci.yml runs on pull_request to master:
- Build test: verify standard and slim targets build for amd64+arm64
- Size check: report image sizes, warn if over baseline
- Smoke test: start container in standalone mode, verify HTTP 200

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
Replace single-job workflow with three parallel jobs:
- build-push-standard: tags v<version> + latest
- build-push-slim: tags v<version>-slim + slim
- build-push-ai: tags v<version>-ai (depends on standard)

Upgrade all Actions: checkout@v4, setup-qemu-action@v3,
setup-buildx-action@v3, login-action@v3, build-push-action@v6.
Replace deprecated set-output with GITHUB_OUTPUT.

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
Document standard, slim, and AI image variants with size estimates.
Add migration section for users upgrading from v3.2.0 who need AI
features to switch to the -ai tag.

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
eclipse-temurin:17-jre-alpine only supports amd64. Switch slim to
JDK 21 alpine which supports both amd64 and arm64. Nacos 3.x is
compatible with JDK 17+ so JDK 21 works without issues.

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
Nacos uses RocksDB via JNI which requires libstdc++.so.6. Alpine does
not include it by default, causing startup failure with
UnsatisfiedLinkError.

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
Standard ~570MB, slim ~426MB (uncompressed). Previous baselines
(400MB/300MB) were based on compressed size estimates. Adjust to
600MB/450MB for uncompressed sizes.

Signed-off-by: cxhello <caixiaohuichn@gmail.com>
@cxhello

cxhello commented May 26, 2026

Copy link
Copy Markdown
Member Author

Closing in favor of #507 (smaller scope: CI-only improvements without Dockerfile changes).

@cxhello cxhello closed this May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v3.2.0 image size regression: 294MB → 1.26GB (4.3x increase)

1 participant