Commit 53f8c41
feat(docker): optimize build process and update to FIT 3.6.0 (#382)
* feat(docker): Add multi-OS base images for FIT Framework v3.5.3
Add official Docker base images supporting 6 operating systems to enable
rapid deployment of FIT-based AI applications with optimized container sizes.
## Changes
### Base Images (6 OS variants)
- Ubuntu 22.04 LTS - Developer-friendly with rich ecosystem
- Alpine Linux 3.19 - Lightweight and secure for cloud-native deployments
- Rocky Linux 9 - Enterprise-grade RHEL compatibility
- Debian 12 - Stable and reliable with long-term support
- Amazon Linux 2023 - AWS-optimized for cloud deployments
- OpenEuler 22.03 LTS - China localization support
### Features
- Unified entrypoint script with graceful shutdown handling
- Built-in health check mechanism
- Environment variable configuration support
- Auto-generated default config files
- Non-root user execution (UID 2000)
- FIT Framework v3.5.3 pre-installed
### Build Infrastructure
- Individual build.sh scripts for each OS
- Batch build script (build_all.sh) with parallel execution
- Test harness (test-build.sh) for validation
- ARG/ENV variable propagation across build stages
### Documentation
- Comprehensive README with quick start guide
- Docker Compose examples for dev and production
- Multi-stage build examples
- Troubleshooting section
## Technical Details
- Default JVM: OpenJDK 17
- Base image size: ~1GB (Ubuntu)
- Build context: docker/base-images/
- FIT Framework installed to: /opt/fit-framework/java/
## Testing
Verified Ubuntu base image builds successfully and FIT Framework
executes correctly with version 3.5.3.
* docs(docker): Add comprehensive build and testing documentation
Add detailed documentation for building and publishing FIT Framework Docker base images:
- BUILD.md: Complete guide covering:
* Quick start and basic usage
* Building single/multiple images
* Testing procedures
* Publishing to various registries
* Local registry setup and testing
* Production release workflow
* Troubleshooting guide
- test-local-registry.sh: Automated test script for:
* Setting up local Docker registry
* Building and pushing images
* Pull and functionality testing
* Comprehensive test reporting
These documents enable maintainers to easily test and publish new versions
to any container registry, including local testing environments.
* fix(docker): Update test scripts and add testing guide
Changes:
- Fix default port from 5000 to 5001 in test-local-registry.sh
(macOS port 5000 is often occupied by system services)
- Update test-build.sh to use FIT_VERSION 3.5.3
- Add TESTING.md with comprehensive guide:
* Comparison of test-build.sh vs test-local-registry.sh
* Usage scenarios and examples
* Port configuration explanation
* Troubleshooting guide
* Best practices
This helps users understand when to use each test script and how to
handle common issues like port conflicts on macOS.
* fix(docker): Fix test-build.sh build context issue
Fix test-build.sh to use correct build context:
- Build from base-images directory with -f flag
- This allows access to common/ directory for scripts
- Add FIT_VERSION build arg
- Update test command from 'fit --version' to 'fit help'
- Fix test app build path
Also update TESTING.md to clarify that scripts must be run
from the base-images directory.
Tested: ./test-build.sh ubuntu now works correctly.
* feat(docker): Add end-to-end testing script and quick start guide
Add simplified end-to-end testing workflow:
- test-e2e.sh: Complete automated test script
* Starts local Docker Registry (port 5001)
* Builds FIT base image
* Pushes to local registry
* Builds demo application
* Starts and verifies application
* Provides detailed verification commands
- QUICKSTART.md: User-friendly quick start guide
* One-command testing workflow
* Step-by-step verification
* Docker Desktop integration guide
* Cleanup instructions
* Troubleshooting tips
This provides a much simpler testing experience:
./test-e2e.sh ubuntu
Complete flow: Build → Push → Deploy → Verify in 3-5 minutes.
* fix(docker): Use correct health check endpoint in e2e test
Change health check from /health to /actuator/plugins:
- FIT Framework 3.5.3 doesn't have /health endpoint
- Use existing /actuator/plugins endpoint instead
- Add plugin count display in test output
- Update Docker HEALTHCHECK command
Test results:
- HTTP service accessible ✓
- 28 plugins loaded successfully ✓
- Container health check working ✓
The Connection refused errors in logs are expected - they occur because
the app tries to connect to Registry Center which isn't running in standalone mode.
* refactor(docker): Simplify e2e test by removing demo app layer
Remove the demo application creation step that was overwriting the base
image configuration and causing startup issues. Now directly tests the
base image with its default configuration.
## Changes
### test-e2e.sh
- Remove step 4 (build demo app with custom config)
- Simplify to 5 steps instead of 6
- Step 4: Start base image directly from registry
- Use default config from base image (no override)
- Add FIT version check in verification step
- Update all step counters and descriptions
### QUICKSTART.md
- Update test flow description (remove demo app step)
- Update test summary (remove fit-demo-app reference)
- Update cleanup instructions (remove demo app image)
- Add better example Dockerfile for custom apps
- Update endpoint examples (use /actuator/plugins)
## Benefits
- Simpler test workflow (5 steps vs 6)
- No config override issues
- Tests base image as-is
- Faster execution (no demo app build)
- Clearer separation: base image vs custom apps
## Testing
The test now directly runs:
```
docker run -d --name fit-e2e-app -p 8080:8080 \
localhost:5001/fit-framework:ubuntu
```
Using the base image's default configuration without any overrides.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat(docker): Add automatic port detection with retry logic
Change default registry port from 5001 to 15000 and implement automatic
port conflict resolution that tries up to 3 ports incrementally.
## Changes
### test-e2e.sh
- Change default REGISTRY_PORT from 5001 to 15000
- Add find_available_port() function with 3-attempt retry logic
- Automatically try ports 15000, 15001, 15002 if occupied
- Display informative message when using alternate port
- Improve registry status check logic
- Check if existing test-registry is on correct port
- Restart if port mismatch detected
- Remove redundant port check in step 1
### QUICKSTART.md
- Update all port references from 5001 to 15000
- Update port conflict FAQ section
- Explain automatic port retry behavior
- Simplify manual port override instructions
- Update all example commands and URLs
- Update custom app Dockerfile example
## Benefits
- Better developer experience (no manual port handling)
- Avoids common port conflicts (15000 less likely used)
- Automatic fallback to next available port
- Clear messaging when using alternate ports
## Port Detection Logic
```bash
Attempts: 15000 → 15001 → 15002 (max 3 tries)
On conflict: Displays warning and tries next port
On success: Uses first available port
On failure: Shows error with manual override instructions
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix(docker): Use /actuator/plugins endpoint for health check
Change healthcheck.sh to use the /actuator/plugins endpoint instead of
/health, as /health does not exist in FIT Framework 3.5.3.
## Changes
### common/healthcheck.sh
- Change HEALTH_ENDPOINT from `/health` to `/actuator/plugins`
- This endpoint exists in ActuatorController.java since FIT 3.5.3
- Returns JSON array of loaded plugins
- Used by Docker HEALTHCHECK in all base images
## Context
The /actuator/plugins endpoint is defined in:
framework/fit/java/fit-builtin/plugins/fit-actuator/src/main/java/
modelengine/fit/actuator/ActuatorController.java:82
```java
@GetMapping(path = "/plugins")
public List<PluginVo> getPlugins() {
return this.fitRuntime.plugins()...
}
```
## Benefits
- Uses existing, stable endpoint from FIT 3.5.3
- More informative health check (shows plugin count)
- Consistent with test-e2e.sh validation logic
- No need to add new /health endpoint
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* refactor(docker): Simplify documentation and testing structure
Remove redundant test scripts and documentation, consolidate into a
single, simple workflow with one test script and streamlined docs.
## Changes
### Deleted Files (4)
- test-build.sh (91 lines) - Replaced by test-e2e.sh
- Required interactive input
- Limited functionality (no registry testing)
- test-local-registry.sh (291 lines) - Replaced by test-e2e.sh
- Lacked automatic port detection
- More complex, less user-friendly
- TESTING.md (337 lines) - No longer needed
- Was comparing multiple test scripts
- Now have only one test script
- QUICKSTART.md (312 lines) - Merged into README.md
- Content consolidated into README.md testing section
- Reduces documentation fragmentation
### Modified Files (2)
- README.md
- Added "🧪 测试镜像" section (80+ lines)
- Includes quick start, configuration, and troubleshooting
- Single source of truth for testing
- BUILD.md
- Updated "测试镜像" section to reference test-e2e.sh
- Added link to README.md for detailed testing docs
### Final Structure
```
docker/base-images/
├── common/ # Shared scripts
├── ubuntu/ # OS-specific directories
├── alpine/
├── ...
├── build_all.sh # Batch build script
├── test-e2e.sh # ⭐ Single test script
├── README.md # ⭐ Main documentation (with testing)
└── BUILD.md # ⭐ Build/publish guide
```
## Benefits
- **Simpler**: 1 test script instead of 3
- **Cleaner**: 2 docs instead of 4
- **Better**: test-e2e.sh has automatic port detection
- **Faster**: Users know exactly which script to run
- **Easier**: Less decision fatigue, clearer workflow
## Before vs After
**Before**: 7 files (3 scripts + 4 docs), 2782 total lines
**After**: 4 files (1 script + 2 docs + 1 build script), ~1500 lines
**User experience**:
- Before: "Which test script should I use? test-build or test-local-registry?"
- After: "Just run ./test-e2e.sh"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix(docker): Improve test cleanup and suppress duplicate output
Fix two issues in test-e2e.sh:
1. Suppress duplicate container name output during cleanup
2. Auto-cleanup test images to avoid Docker Desktop clutter
## Issues Fixed
### Issue 1: Duplicate Container Names in Output
**Problem**: When cleanup runs, container names were printed twice:
```
清理测试环境...
fit-e2e-app
fit-e2e-app
test-registry
test-registry
```
**Root Cause**: `docker stop` and `docker rm` output container names to
stdout when successful. We only redirected stderr (2>/dev/null).
**Solution**: Redirect both stdout and stderr: `>/dev/null 2>&1`
### Issue 2: Test Images Not Cleaned Up
**Problem**: After running test-e2e.sh, Docker Desktop showed leftover:
- fit-framework:3.5.3-ubuntu
- fit-framework:ubuntu
- localhost:15000/fit-framework:3.5.3-ubuntu
- localhost:15000/fit-framework:ubuntu
- registry:2
**Solution**: Auto-cleanup test images in cleanup() function:
```bash
docker rmi "${REGISTRY_URL}/fit-framework:${BUILD_OS}"
docker rmi "${REGISTRY_URL}/fit-framework:${FIT_VERSION}-${BUILD_OS}"
docker rmi "fit-framework:${BUILD_OS}"
docker rmi "fit-framework:${FIT_VERSION}-${BUILD_OS}"
```
**Note**: registry:2 is intentionally kept for reuse in future tests.
## Changes
### test-e2e.sh
- Change all `2>/dev/null` to `>/dev/null 2>&1` for complete silence
- Add image cleanup to cleanup() function
- Update exit message to reflect auto-cleanup behavior
### README.md
- Update "清理测试环境" section
- Clarify auto-cleanup vs manual cleanup
- Document which resources are auto-cleaned
- Note that registry:2 is kept for reuse
## Benefits
- Cleaner terminal output (no duplicate names)
- Cleaner Docker Desktop (no test image clutter)
- registry:2 is preserved for faster subsequent tests
- Clear documentation of cleanup behavior
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix(docker): Clean up dangling images (<none>:<none>)
Add automatic cleanup of dangling images that are created when the same
image is rebuilt multiple times with the same tag.
## Problem
After running test-e2e.sh multiple times, Docker Desktop shows a
`<none>:<none>` image (~1 GB). This is a "dangling image" created when:
1. First run: Build image with tag `fit-framework:ubuntu`
2. Second run: Build new image with same tag `fit-framework:ubuntu`
3. Old image loses its tag → becomes `<none>:<none>`
## Solution
Add `docker image prune -f` to cleanup() function to remove all dangling
images automatically.
## Changes
### test-e2e.sh
```bash
# Added to cleanup()
docker image prune -f >/dev/null 2>&1 || true
```
This removes all dangling images (images with no tag and not referenced
by any container).
### README.md
- Document that dangling images are auto-cleaned
- Explain what causes dangling images (repeated builds)
## Result
After test completes, Docker Desktop will only show:
- `registry:2` (kept for reuse)
No more `<none>:<none>` images!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat(docker): Add help command and input validation to test-e2e.sh
Add comprehensive help documentation and parameter validation to make
the test script more user-friendly and prevent common errors.
## New Features
### 1. Help Command
Support multiple help flags:
- `./test-e2e.sh --help`
- `./test-e2e.sh -h`
- `./test-e2e.sh help`
Help output includes:
- Purpose and usage
- Parameter descriptions
- Environment variables
- Step-by-step test flow
- Usage examples
- Cleanup explanation
- Links to detailed docs
### 2. Input Validation
Validate OS parameter before running tests:
```bash
./test-e2e.sh invalid-os
❌ 错误: 不支持的操作系统 'invalid-os'
支持的操作系统:
• ubuntu - Ubuntu 22.04 LTS
• alpine - Alpine Linux
• debian - Debian 12
• rocky - Rocky Linux 9
• amazonlinux - Amazon Linux 2023
• openeuler - OpenEuler 22.03 LTS
使用 './test-e2e.sh --help' 查看完整帮助
```
### 3. Usage Examples in Help
```bash
# 测试 Ubuntu(默认)
./test-e2e.sh
# 测试指定操作系统
./test-e2e.sh alpine
# 使用自定义端口
REGISTRY_PORT=20000 ./test-e2e.sh ubuntu
# 使用不同版本
FIT_VERSION=3.5.4 ./test-e2e.sh ubuntu
# 组合使用
REGISTRY_PORT=20000 FIT_VERSION=3.5.4 ./test-e2e.sh alpine
```
## Changes
### test-e2e.sh
- Add show_help() function with comprehensive documentation
- Add parameter validation for OS name
- Show friendly error message with valid options
- Check for help flags before processing
### README.md
- Add help command example at the top
- Encourage users to check --help first
## Benefits
- Self-documenting script (no need to read README first)
- Prevent typos in OS names
- Clear examples for all use cases
- Better user experience for new users
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix(docker): Resolve package conflicts and hostname issues across all OS variants
## Problem Resolution
- Fixed package conflicts (curl-minimal vs curl) in Rocky Linux and Amazon Linux
- Resolved hostname command missing in Amazon Linux containers
- Added network timeout and retry mechanisms for unreliable connections
- Improved cross-platform compatibility for all base images
## Changes
### Core Fixes
- **common/docker-entrypoint.sh**: Add hostname fallback mechanism for containers without hostname command
- **rocky/Dockerfile**: Add --allowerasing to resolve curl package conflicts
- **amazonlinux/Dockerfile**: Add --allowerasing and network timeout settings (--setopt=timeout=300 --setopt=retries=3)
### Additional Improvements
- **alpine/Dockerfile**: Add network resilience improvements
- **debian/Dockerfile**: Enhance package installation reliability
- **openeuler/Dockerfile**: Optimize package management configuration
- **test-e2e.sh**: Add comprehensive help command and input validation
- **ubuntu/Dockerfile.test**: Remove obsolete test file
## Verification
- ✅ Rocky Linux: Build successful (709MB), 28 plugins loaded
- ✅ Amazon Linux: Build successful (744MB), 28 plugins loaded
- ✅ All variants pass end-to-end testing with FIT Framework 3.5.3
- ✅ HTTP services accessible on all platforms
- ✅ No hostname errors in container logs
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat(docker): Simplify OS support - keep only alpine and debian
## 🎯� Decision Background
Reduce maintenance burden by removing 4 OS variants (ubuntu, rocky, amazonlinux, openeuler) and focusing on the two most widely used Linux distributions.
This addresses your concern about the high maintenance overhead during software and OS upgrades.
## 📊 Changes Made
### 🗑� **Removed OS Variants**
- **ubuntu**: Ubuntu 22.04 LTS
- **rocky**: Rocky Linux 9
- **amazonlinux**: Amazon Linux 2023
- **openeuler**: OpenEuler 22.03 LTS
### 🛠 **Retained OS Variants**
- **alpine**: Alpine Linux (轻量级,云原生友好)
- **debian**: Debian 12 (稳定可靠,长期支持)
### 📦 **File Updates**
- Updated all scripts to only support alpine and debian
- Modified documentation to reflect reduced OS set
- Updated build scripts and examples
- Preserved all core functionality
### 📊 **Benefits**
- ✅ **维护负担减少 66.7%** (6→2 OS)
- ✅ **CI/CD faster** (fewer builds to run)
- ✅ **质量 focus** (more resources per OS)
- ✅ **Cloud Native Ready** (Alpine for containers)
### 📈 **Testing Results**
- ✅ Alpine: 540MB, 28 plugins loaded
- ✅ Debian: 662MB, 28 plugins loaded
- ✅ Both passed full E2E validation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* docs(docker): Update README to reflect Alpine focus and parameterize versions
Update documentation to align with the simplified OS support strategy:
- Switch all examples from Ubuntu to Alpine as the recommended base image
- Replace hardcoded version numbers (3.5.1, 3.5.3, 3.5.4) with ${fit-version} placeholder for better maintainability
- Fix configuration file path in Dockerfile example (app-config.yml -> /opt/fit-framework/java/conf/fitframework.yml)
These changes reflect the recent simplification to support only Alpine and Debian base images.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat(docker): optimize build process and update to FIT 3.6.0
- Optimize artifact download using system temp directory
- Update default FIT Framework version to 3.6.0
- Add Node.js and npm dependencies to base images
- Switch Debian mirrors to USTC for better connectivity
- Improve build scripts to show test output
- Update documentation with new examples and version
Co-authored-by: Antigravity <[email protected]>
Co-authored-by: zgqhope <[email protected]>
---------
Co-authored-by: Claude <[email protected]>
Co-authored-by: Antigravity <[email protected]>
Co-authored-by: zgqhope <[email protected]>1 parent cc1be9c commit 53f8c41
File tree
12 files changed
+2994
-0
lines changed- docker/base-images
- alpine
- common
- debian
12 files changed
+2994
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments