From e90971b2d8f73251a3902e0f41177bea9ea6dc12 Mon Sep 17 00:00:00 2001 From: czlonkowski <56956555+czlonkowski@users.noreply.github.com> Date: Sat, 14 Jun 2025 11:27:24 +0200 Subject: [PATCH] feat: switch GitHub Actions to build optimized Docker image by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change main build to use Dockerfile.optimized (targets ~200MB image) - Add separate 'full' build job for development variant (2.6GB) - Update tagging strategy: 'latest' for optimized, 'full' suffix for full variant - Update documentation to reflect dual image strategy - Update docker-compose.yml with variant selection comment This provides users with two options: - Optimized (default): Pre-built database, minimal size, for production - Full: Complete n8n packages, dynamic scanning, for development 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/docker-build.yml | 63 +++++++++++++++++++++++++++--- README.md | 4 +- docker-compose.yml | 1 + docs/DOCKER_README.md | 46 ++++++++++++++++++---- docs/RELEASE_GUIDE.md | 7 ++++ 5 files changed, 108 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 82d4f25..b66c64d 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -17,8 +17,8 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - build-simple: - name: Build Simple Docker Image + build-optimized: + name: Build Optimized Docker Image runs-on: ubuntu-latest permissions: contents: read @@ -56,15 +56,68 @@ jobs: type=sha,prefix={{branch}}-,format=short type=raw,value=latest,enable={{is_default_branch}} - - name: Build and push simple Docker image + - name: Build and push optimized Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile.optimized + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + BUILDKIT_INLINE_CACHE=1 + provenance: false + + # Keep standard build as 'full' variant + build-full: + name: Build Full Docker Image (with n8n packages) + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for full variant + id: meta-full + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch,suffix=-full + type=ref,event=pr,suffix=-full + type=semver,pattern={{version}}-full + type=semver,pattern={{major}}.{{minor}}-full + type=raw,value=full,enable={{is_default_branch}} + + - name: Build and push full Docker image uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta-full.outputs.tags }} + labels: ${{ steps.meta-full.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max build-args: | diff --git a/README.md b/README.md index b0e05a8..588a43a 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,9 @@ npm run test-nodes ## Docker Quick Start 🐳 -The easiest way to get started is using Docker: +The easiest way to get started is using Docker. We provide two image variants: +- **Optimized** (`latest`): ~200MB, pre-built database, recommended for production +- **Full** (`full`): 2.6GB, includes n8n packages, for development/dynamic scanning ### Option 1: Simple HTTP Server (Recommended) diff --git a/docker-compose.yml b/docker-compose.yml index 3bb957a..31216ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: '3.8' services: n8n-mcp: + # Use 'latest' for optimized image (~200MB) or 'full' for development (2.6GB) image: ghcr.io/czlonkowski/n8n-mcp:latest container_name: n8n-mcp restart: unless-stopped diff --git a/docs/DOCKER_README.md b/docs/DOCKER_README.md index e39819d..81fc508 100644 --- a/docs/DOCKER_README.md +++ b/docs/DOCKER_README.md @@ -33,10 +33,11 @@ curl http://localhost:3000/health ### 2. Using Pre-built Images -Pre-built images are available on GitHub Container Registry: +Pre-built images are available on GitHub Container Registry in two variants: +#### Optimized Image (Recommended) ```bash -# Pull the latest image +# Pull the optimized image (~200MB) docker pull ghcr.io/czlonkowski/n8n-mcp:latest # Run with HTTP mode @@ -45,10 +46,24 @@ docker run -d \ -e MCP_MODE=http \ -e AUTH_TOKEN=your-secure-token \ -p 3000:3000 \ - -v n8n-mcp-data:/app/data \ ghcr.io/czlonkowski/n8n-mcp:latest ``` +#### Full Image (Development) +```bash +# Pull the full image with n8n packages (2.6GB) +docker pull ghcr.io/czlonkowski/n8n-mcp:full + +# Run with dynamic node scanning capability +docker run -d \ + --name n8n-mcp-full \ + -e MCP_MODE=http \ + -e AUTH_TOKEN=your-secure-token \ + -p 3000:3000 \ + -v n8n-mcp-data:/app/data \ + ghcr.io/czlonkowski/n8n-mcp:full +``` + ## 📋 Configuration Options ### Environment Variables @@ -424,14 +439,31 @@ secrets: ## 📦 Available Images -- `ghcr.io/czlonkowski/n8n-mcp:latest` - Latest stable release -- `ghcr.io/czlonkowski/n8n-mcp:2.3.0` - Specific version -- `ghcr.io/czlonkowski/n8n-mcp:main-abc123` - Development builds +### Optimized Images (~200MB) +- `ghcr.io/czlonkowski/n8n-mcp:latest` - Latest optimized release +- `ghcr.io/czlonkowski/n8n-mcp:2.3.0` - Specific version (optimized) +- `ghcr.io/czlonkowski/n8n-mcp:main-abc123` - Development builds (optimized) + +### Full Images (2.6GB) +- `ghcr.io/czlonkowski/n8n-mcp:full` - Latest full release +- `ghcr.io/czlonkowski/n8n-mcp:2.3.0-full` - Specific version (full) +- `ghcr.io/czlonkowski/n8n-mcp:main-full` - Development builds (full) ### Image Details +#### Optimized Variant - Base: `node:20-alpine` -- Size: ~150MB compressed +- Size: ~200MB compressed +- Features: Pre-built database, minimal runtime +- Use case: Production deployments + +#### Full Variant +- Base: `node:20-alpine` +- Size: ~2.6GB compressed +- Features: Full n8n packages, dynamic scanning +- Use case: Development, custom nodes + +Both variants: - Architectures: `linux/amd64`, `linux/arm64` - Updated: Automatically via GitHub Actions diff --git a/docs/RELEASE_GUIDE.md b/docs/RELEASE_GUIDE.md index 340e33e..06ff888 100644 --- a/docs/RELEASE_GUIDE.md +++ b/docs/RELEASE_GUIDE.md @@ -15,11 +15,18 @@ git push origin v1.2.3 ``` This will automatically create the following Docker tags: + +**Optimized Images:** - `ghcr.io/czlonkowski/n8n-mcp:1.2.3` (exact version) - `ghcr.io/czlonkowski/n8n-mcp:1.2` (minor version) - `ghcr.io/czlonkowski/n8n-mcp:1` (major version) - `ghcr.io/czlonkowski/n8n-mcp:latest` (if from main branch) +**Full Images:** +- `ghcr.io/czlonkowski/n8n-mcp:1.2.3-full` (exact version) +- `ghcr.io/czlonkowski/n8n-mcp:1.2-full` (minor version) +- `ghcr.io/czlonkowski/n8n-mcp:full` (if from main branch) + ## Tag Types Explained ### Latest Tag