refactor: make optimized Dockerfile the default - remove full variant

- Rename Dockerfile.optimized to Dockerfile (now the default)
- Keep old Dockerfile as Dockerfile.old for reference
- Update GitHub Actions to use default Dockerfile
- Remove build-full job - only one image variant now
- Remove docker-compose.optimized.yml and other variants
- Update all documentation to reflect single image approach

The optimized 283MB image is now the only n8n-MCP Docker image.
This simplifies the user experience and provides the best solution
for all use cases.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-06-14 14:00:36 +02:00
parent e90971b2d8
commit 88dd66bb7a
12 changed files with 167 additions and 408 deletions

View File

@@ -1,25 +1,18 @@
# Stage 1: Dependencies
# Optimized Dockerfile - builds database at build time, minimal runtime image
# Stage 1: Dependencies (includes n8n for building)
FROM node:20-alpine AS deps
WORKDIR /app
COPY package*.json ./
# Configure npm for better reliability in CI
# Configure npm for reliability
RUN npm config set fetch-retries 5 && \
npm config set fetch-retry-mintimeout 20000 && \
npm config set fetch-retry-maxtimeout 120000 && \
npm config set fetch-timeout 300000
# Install all dependencies including dev for building
# Install all dependencies including n8n packages
RUN npm ci
# Stage 2: Production Dependencies
FROM node:20-alpine AS prod-deps
WORKDIR /app
COPY package*.json ./
# Copy all dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
# Prune to production only (much faster than fresh install)
RUN npm prune --omit=dev
# Stage 3: Builder
# Stage 2: Builder (compiles TypeScript)
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
@@ -28,43 +21,62 @@ COPY . .
# Build TypeScript
RUN npm run build
# Stage 4: Runtime
# Stage 3: Database Builder (extracts all node info and builds database)
FROM builder AS db-builder
WORKDIR /app
# Clone n8n-docs for documentation (if available)
RUN apk add --no-cache git && \
git clone https://github.com/n8n-io/n8n-docs.git /tmp/n8n-docs || true
ENV N8N_DOCS_PATH=/tmp/n8n-docs
# Build the complete database with source code
RUN mkdir -p data && \
node dist/scripts/rebuild-optimized.js
# Stage 4: Minimal Runtime (no n8n packages)
FROM node:20-alpine AS runtime
WORKDIR /app
# Install only essential tools (flock is in util-linux)
RUN apk add --no-cache curl su-exec util-linux && \
# Install only essential runtime tools
RUN apk add --no-cache curl && \
rm -rf /var/cache/apk/*
# Copy production dependencies from prod-deps stage
COPY --from=prod-deps /app/node_modules ./node_modules
COPY package*.json ./
# Create package.json with only runtime dependencies
RUN echo '{ \
"name": "n8n-mcp-runtime", \
"version": "1.0.0", \
"private": true, \
"dependencies": { \
"@modelcontextprotocol/sdk": "^1.12.1", \
"better-sqlite3": "^11.10.0", \
"sql.js": "^1.13.0", \
"express": "^5.1.0", \
"dotenv": "^16.5.0" \
} \
}' > package.json
# Install only runtime dependencies
RUN npm config set fetch-retries 5 && \
npm config set fetch-retry-mintimeout 20000 && \
npm install --production --no-audit --no-fund
# Copy built application
COPY --from=builder /app/dist ./dist
# Create data directory
RUN mkdir -p /app/data
# Copy pre-built database with all source code
COPY --from=db-builder /app/data/nodes.db ./data/
# Copy necessary source files for database initialization
COPY src/database/schema.sql ./src/database/
COPY scripts ./scripts
# Copy necessary files
COPY .env.example .env.example
COPY LICENSE LICENSE
COPY README.md README.md
# Copy minimal required files
COPY src/database/schema-optimized.sql ./src/database/
COPY .env.example ./
# Add container labels
LABEL org.opencontainers.image.source="https://github.com/czlonkowski/n8n-mcp"
LABEL org.opencontainers.image.description="n8n MCP Server - Simple Version"
LABEL org.opencontainers.image.description="n8n MCP Server - Optimized Version"
LABEL org.opencontainers.image.licenses="Sustainable-Use-1.0"
LABEL org.opencontainers.image.vendor="n8n-mcp"
LABEL org.opencontainers.image.title="n8n-mcp"
LABEL org.opencontainers.image.title="n8n-mcp-optimized"
# Create data directory and fix permissions
RUN mkdir -p /app/data && \
addgroup -g 1001 -S nodejs && \
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs /app
@@ -79,9 +91,9 @@ USER nodejs
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://127.0.0.1:3000/health || exit 1
# Entrypoint
# Optimized entrypoint
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["node", "dist/mcp/index.js"]