|
| 1 | +# Multi-Architecture Docker Support |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This project now supports multi-architecture Docker images that can run on: |
| 6 | + |
| 7 | +- **Linux** (amd64, arm64) |
| 8 | +- **macOS** (via Docker Desktop) |
| 9 | +- **Windows** (via Docker Desktop with WSL2) |
| 10 | + |
| 11 | +## Architecture Support |
| 12 | + |
| 13 | +### Supported Platforms |
| 14 | + |
| 15 | +- `linux/amd64` - Standard x86_64 Linux systems |
| 16 | +- `linux/arm64` - ARM64 Linux systems (Apple Silicon, ARM servers) |
| 17 | + |
| 18 | +### Running on Different Platforms |
| 19 | + |
| 20 | +#### Linux |
| 21 | + |
| 22 | +```bash |
| 23 | +# Native support - will automatically use the correct architecture |
| 24 | +docker run ghcr.io/g-core/fastedge-mcp-server:latest |
| 25 | +``` |
| 26 | + |
| 27 | +#### macOS (Intel & Apple Silicon) |
| 28 | + |
| 29 | +```bash |
| 30 | +# Docker Desktop automatically pulls the correct architecture |
| 31 | +# Intel Macs: linux/amd64 |
| 32 | +# Apple Silicon Macs: linux/arm64 |
| 33 | +docker run ghcr.io/g-core/fastedge-mcp-server:latest |
| 34 | +``` |
| 35 | + |
| 36 | +#### Windows |
| 37 | + |
| 38 | +```bash |
| 39 | +# Docker Desktop with WSL2 backend |
| 40 | +docker run ghcr.io/g-core/fastedge-mcp-server:latest |
| 41 | +``` |
| 42 | + |
| 43 | +## Building Multi-Architecture Images |
| 44 | + |
| 45 | +### Base Image |
| 46 | + |
| 47 | +The base image is built using the existing workflow: |
| 48 | + |
| 49 | +```bash |
| 50 | +# Use the build-docker-base-image.yaml workflow |
| 51 | +# Manually triggered via GitHub Actions UI or API |
| 52 | +``` |
| 53 | + |
| 54 | +### Main Image |
| 55 | + |
| 56 | +The main application image is built using the multi-architecture base: |
| 57 | + |
| 58 | +```bash |
| 59 | +# Use the build-push-docker action with platforms: linux/amd64,linux/arm64 |
| 60 | +``` |
| 61 | + |
| 62 | +## Development Notes |
| 63 | + |
| 64 | +### Local Multi-Architecture Building |
| 65 | + |
| 66 | +#### Full Multi-Architecture Build (Requires Network Connectivity) |
| 67 | + |
| 68 | +For environments with proper network connectivity and ARM64 emulation: |
| 69 | + |
| 70 | +```bash |
| 71 | +# Set up buildx with docker-container driver (one-time setup) |
| 72 | +docker buildx create --name multiarch --driver docker-container --use |
| 73 | +docker buildx inspect --bootstrap |
| 74 | + |
| 75 | +# Build base image for multiple architectures |
| 76 | +docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile-base -t fastedge-mcp-server-base:latest --load . |
| 77 | + |
| 78 | +# Build main image for multiple architectures |
| 79 | +docker buildx build --platform linux/amd64,linux/arm64 --build-arg BASE_IMAGE=fastedge-mcp-server-base:latest -t fastedge-mcp-server:latest --load . |
| 80 | +``` |
| 81 | + |
| 82 | +#### Single Architecture Build (Recommended for Local Development) |
| 83 | + |
| 84 | +If you encounter network issues or want faster builds: |
| 85 | + |
| 86 | +```bash |
| 87 | +# Use default driver (no special setup required) |
| 88 | +docker buildx use default |
| 89 | + |
| 90 | +# Build base image for current platform only |
| 91 | +docker build -f Dockerfile-base -t fastedge-mcp-server-base:latest . |
| 92 | + |
| 93 | +# Build main image for current platform |
| 94 | +docker build --build-arg BASE_IMAGE=fastedge-mcp-server-base:latest -t fastedge-mcp-server:latest . |
| 95 | +``` |
| 96 | + |
| 97 | +### Architecture-Specific Considerations |
| 98 | + |
| 99 | +1. **Node.js Binaries**: The Dockerfile-base now automatically detects the target architecture and downloads the appropriate Node.js binary |
| 100 | +2. **Rust Compilation**: Rust toolchain supports cross-compilation for both amd64 and arm64 |
| 101 | +3. **npm Dependencies**: Native dependencies are compiled for the target architecture during the build process |
| 102 | + |
| 103 | +### Limitations |
| 104 | + |
| 105 | +- **Windows Containers**: Not supported due to complexity and requirement for Windows hosts |
| 106 | +- **Performance**: ARM64 images may have slightly different performance characteristics |
| 107 | +- **Build Time**: Multi-architecture builds take longer due to building for multiple platforms |
| 108 | + |
| 109 | +## Troubleshooting |
| 110 | + |
| 111 | +### Platform-Specific Issues |
| 112 | + |
| 113 | +If you encounter platform-specific issues, you can force a specific architecture: |
| 114 | + |
| 115 | +```bash |
| 116 | +# Force amd64 on any platform |
| 117 | +docker run --platform linux/amd64 ghcr.io/g-core/fastedge-mcp-server:latest |
| 118 | + |
| 119 | +# Force arm64 on any platform (if available) |
| 120 | +docker run --platform linux/arm64 ghcr.io/g-core/fastedge-mcp-server:latest |
| 121 | +``` |
| 122 | + |
| 123 | +### Build Issues |
| 124 | + |
| 125 | +Common issues and solutions when building multi-architecture images: |
| 126 | + |
| 127 | +#### 1. "Multi-platform build is not supported for the docker driver" |
| 128 | + |
| 129 | +**Problem**: Using the default Docker driver which doesn't support multi-platform builds. |
| 130 | + |
| 131 | +**Solution**: |
| 132 | + |
| 133 | +```bash |
| 134 | +# Create and use a docker-container builder |
| 135 | +docker buildx create --name multiarch --driver docker-container --use |
| 136 | +docker buildx inspect --bootstrap |
| 137 | +``` |
| 138 | + |
| 139 | +**Alternative**: Use single-platform builds with the default driver: |
| 140 | + |
| 141 | +```bash |
| 142 | +docker buildx use default |
| 143 | +docker build -f Dockerfile-base -t fastedge-mcp-server-base:latest . |
| 144 | +``` |
| 145 | + |
| 146 | +#### 2. Network connectivity issues (IPv6) |
| 147 | + |
| 148 | +**Problem**: `dial tcp [IPv6]:443: connect: network is unreachable` |
| 149 | + |
| 150 | +**Solutions**: |
| 151 | + |
| 152 | +```bash |
| 153 | +# Option 1: Use default driver (often has better network compatibility) |
| 154 | +docker buildx use default |
| 155 | +docker build -f Dockerfile-base -t fastedge-mcp-server-base:latest . |
| 156 | + |
| 157 | +# Option 2: Configure Docker daemon to prefer IPv4 |
| 158 | +# Edit /etc/docker/daemon.json: |
| 159 | +# { |
| 160 | +# "ipv6": false, |
| 161 | +# "dns": ["8.8.8.8", "8.8.4.4"] |
| 162 | +# } |
| 163 | +# Then: sudo systemctl restart docker |
| 164 | + |
| 165 | +# Option 3: Use Docker registry mirrors |
| 166 | +# Add --registry-mirror flag or configure in daemon.json |
| 167 | +``` |
| 168 | + |
| 169 | +#### 3. "No output specified with docker-container driver" |
| 170 | + |
| 171 | +**Problem**: Warning about build results only staying in cache. |
| 172 | + |
| 173 | +**Solution**: Always specify output with `--load` or `--push`: |
| 174 | + |
| 175 | +```bash |
| 176 | +# Load into local Docker images |
| 177 | +docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile-base -t fastedge-mcp-server-base:latest --load . |
| 178 | + |
| 179 | +# Push to registry (for CI/CD) |
| 180 | +docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile-base -t fastedge-mcp-server-base:latest --push . |
| 181 | +``` |
| 182 | + |
| 183 | +#### 4. General troubleshooting |
| 184 | + |
| 185 | +- Check buildx status: `docker buildx ls` |
| 186 | +- Verify builder capabilities: `docker buildx inspect` |
| 187 | +- Ensure base images support target architectures |
| 188 | +- Test single-platform builds first |
| 189 | +- Use `--progress=plain` for detailed build output |
0 commit comments