Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 72 additions & 71 deletions .github/workflows/build&push.yaml
Original file line number Diff line number Diff line change
@@ -1,102 +1,103 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Publish Docker image
name: Build and Push Docker Images

on:
push:
tags:
- 'v*'

env:
REGISTRY_IMAGE: nacos/nacos-server

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
build-push-standard:
name: Push standard image
runs-on: ubuntu-latest
steps:
- name: Extract Version
id: version_step
run: |
echo "##[set-output name=version;]NACOS_VERSION=${GITHUB_REF#$"refs/tags/v"}"

- name: Check out the repo
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: nacos/nacos-server

- name: Build and push Docker image
uses: docker/build-push-action@v2.3.0
- name: Extract version
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v6
with:
context: build
platforms: linux/amd64,linux/arm64
file: build/Dockerfile
target: standard
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: ${{steps.version_step.outputs.version}}
tags: |
${{ env.REGISTRY_IMAGE }}:v${{ steps.version.outputs.version }}
${{ env.REGISTRY_IMAGE }}:latest

push_to_multi_platforms_registry:
name: Push Docker slim image to Docker Hub
build-push-slim:
name: Push slim image
runs-on: ubuntu-latest
steps:
- name: Extract Version
id: version_step
run: |
echo "##[set-output name=version;]NACOS_VERSION=${GITHUB_REF#$"refs/tags/v"}"

- name: Check out the repo
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
- name: Extract version
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v6
with:
images: nacos/nacos-server
flavor: |
latest=false
context: build
file: build/Dockerfile
target: slim
platforms: linux/amd64,linux/arm64
push: true
tags: |
type=pep440,pattern=v{{version}}-slim
${{ env.REGISTRY_IMAGE }}:v${{ steps.version.outputs.version }}-slim
${{ env.REGISTRY_IMAGE }}:slim

- name: Build and push Docker image
uses: docker/build-push-action@v2.3.0
build-push-ai:
name: Push AI image
runs-on: ubuntu-latest
needs: build-push-standard
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract version
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Pull standard image (retry for Docker Hub propagation)
run: |
for i in $(seq 1 5); do
if docker pull --platform linux/amd64 ${{ env.REGISTRY_IMAGE }}:v${{ steps.version.outputs.version }}; then
echo "Pulled successfully on attempt $i"
exit 0
fi
echo "Attempt $i failed, retrying in 15s..."
sleep 15
done
echo "::error::Failed to pull standard image after 5 attempts"
exit 1
- name: Build and push
uses: docker/build-push-action@v6
with:
context: build
file: build/Dockerfile.AI
platforms: linux/amd64,linux/arm64
file: build/Dockerfile.Slim
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: ${{steps.version_step.outputs.version}}
build-args: NACOS_VERSION=${{ steps.version.outputs.version }}
tags: |
${{ env.REGISTRY_IMAGE }}:v${{ steps.version.outputs.version }}-ai
122 changes: 122 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: CI

on:
pull_request:
branches: [master]

jobs:
build-test:
name: Build Images
runs-on: ubuntu-latest
strategy:
matrix:
target: [standard, slim]
include:
- target: standard
file: build/Dockerfile
- target: slim
file: build/Dockerfile
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Build ${{ matrix.target }}
uses: docker/build-push-action@v6
with:
context: build
file: ${{ matrix.file }}
target: ${{ matrix.target }}
platforms: linux/amd64,linux/arm64
push: false
load: false

size-check:
name: Image Size Check
runs-on: ubuntu-latest
needs: []
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build standard (amd64 only for size check)
uses: docker/build-push-action@v6
with:
context: build
file: build/Dockerfile
target: standard
platforms: linux/amd64
push: false
load: true
tags: nacos-size-check:standard
- name: Build slim (amd64 only for size check)
uses: docker/build-push-action@v6
with:
context: build
file: build/Dockerfile
target: slim
platforms: linux/amd64
push: false
load: true
tags: nacos-size-check:slim
- name: Check image sizes
run: |
STANDARD_SIZE=$(docker image inspect nacos-size-check:standard --format '{{.Size}}')
SLIM_SIZE=$(docker image inspect nacos-size-check:slim --format '{{.Size}}')
STANDARD_MB=$((STANDARD_SIZE / 1024 / 1024))
SLIM_MB=$((SLIM_SIZE / 1024 / 1024))

echo "## Docker Image Size Report" >> $GITHUB_STEP_SUMMARY
echo "| Image | Size |" >> $GITHUB_STEP_SUMMARY
echo "|-------|------|" >> $GITHUB_STEP_SUMMARY
echo "| standard | ${STANDARD_MB} MB |" >> $GITHUB_STEP_SUMMARY
echo "| slim | ${SLIM_MB} MB |" >> $GITHUB_STEP_SUMMARY

# Baseline (uncompressed): standard ≤ 600MB, slim ≤ 450MB
if [ "$STANDARD_MB" -gt 600 ]; then
echo "::warning::Standard image ${STANDARD_MB}MB exceeds 600MB baseline"
fi
if [ "$SLIM_MB" -gt 450 ]; then
echo "::warning::Slim image ${SLIM_MB}MB exceeds 450MB baseline"
fi

smoke-test:
name: Smoke Test (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
matrix:
target: [standard, slim]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build ${{ matrix.target }} image
uses: docker/build-push-action@v6
with:
context: build
file: build/Dockerfile
target: ${{ matrix.target }}
platforms: linux/amd64
push: false
load: true
tags: nacos-smoke:${{ matrix.target }}
- name: Run smoke test
run: |
docker run -d --name nacos-test \
-e MODE=standalone \
-e NACOS_AUTH_TOKEN=VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg= \
-e NACOS_AUTH_IDENTITY_KEY=test \
-e NACOS_AUTH_IDENTITY_VALUE=test \
-p 8848:8848 nacos-smoke:${{ matrix.target }}

echo "Waiting for Nacos (${{ matrix.target }}) to start..."
for i in $(seq 1 60); do
if curl -sf http://localhost:8848/nacos/ > /dev/null 2>&1; then
echo "Nacos is ready after ${i}s"
exit 0
fi
sleep 2
done
echo "::error::Nacos (${{ matrix.target }}) failed to start within 120s"
docker logs nacos-test
exit 1
- name: Cleanup
if: always()
run: docker rm -f nacos-test 2>/dev/null || true
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ This project contains a Docker image meant to facilitate the deployment of [Naco

[**中文**](README_ZH.md)

## Image Variants

| Tag | Base | Size | Use Case |
|-----|------|------|----------|
| `v3.2.x` / `latest` | eclipse-temurin:17-jre | ~300 MB | Production (recommended) |
| `v3.2.x-slim` / `slim` | eclipse-temurin:17-jre-alpine | ~250 MB | Size-constrained environments |
| `v3.2.x-ai` | Based on standard | ~550 MB | AI features (MCP registry, skill scanner) |

### Migrating from v3.2.0

If you were using AI features (skill scanner, MCP registry) with the default `v3.2.0` image, switch to the `-ai` tag:

```yaml
# Before
image: nacos/nacos-server:v3.2.0

# After (with AI features)
image: nacos/nacos-server:v3.2.1-ai

# After (no AI features, smaller image)
image: nacos/nacos-server:v3.2.1
```

## Note

The following environment variables have been **removed** from the default values in the new version(**Nacos 2.2.1**)
Expand Down Expand Up @@ -70,9 +93,13 @@ docker run --name nacos-standalone-derby-v2.5.1 \
NACOS_VERSION=v3.2.1
```

For Mac user with Arm Chip (like M1/M2/M3 series) , you need to add `-slim` after version which support `arm` arch.
All image variants (`latest`, `-slim`, `-ai`) support both `amd64` and `arm64` architectures. The `-slim` variant uses Alpine Linux for a smaller footprint.

```dotenv
# Standard image (recommended)
NACOS_VERSION=v3.2.1

# Slim image (Alpine-based, smaller)
NACOS_VERSION=v3.2.1-slim
```

Expand Down
Loading
Loading