From 9e9a9856f49cbadc653cca5019803896d08dca1e Mon Sep 17 00:00:00 2001 From: moonwalk Date: Wed, 16 Jul 2025 10:27:21 +0200 Subject: [PATCH] Made deployable on Railway (#53) * Rename Dockerfile to __Dockerfile * Update and rename __Dockerfile to Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Rename Dockerfile to Dockerfile.railway * Create Docherfile * Rename Docherfile to Dockerfile * Create railway.json * Update README.md --- Dockerfile | 2 +- Dockerfile.railway | 78 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 3 ++ railway.json | 10 ++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.railway create mode 100644 railway.json diff --git a/Dockerfile b/Dockerfile index 3f3e28d..ced41c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,4 +75,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ # Optimized entrypoint ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] -CMD ["node", "dist/mcp/index.js"] \ No newline at end of file +CMD ["node", "dist/mcp/index.js"] diff --git a/Dockerfile.railway b/Dockerfile.railway new file mode 100644 index 0000000..c5313e1 --- /dev/null +++ b/Dockerfile.railway @@ -0,0 +1,78 @@ +# syntax=docker/dockerfile:1.7 +# Railway-compatible Dockerfile for n8n-mcp + +# --- Stage 1: Builder --- +FROM node:20-alpine AS builder +WORKDIR /app + +# Install system dependencies for native modules +RUN apk add --no-cache python3 make g++ && \ + rm -rf /var/cache/apk/* + +# Copy package files +COPY package*.json tsconfig.json ./ + +# Install all dependencies (including devDependencies for build) +RUN npm ci --no-audit --no-fund + +# Copy source code +COPY src ./src + +# Build the application +RUN npm run build + +# --- Stage 2: Runtime --- +FROM node:20-alpine AS runtime +WORKDIR /app + +# Install system dependencies +RUN apk add --no-cache curl python3 make g++ && \ + rm -rf /var/cache/apk/* + +# Copy package files +COPY package*.json ./ + +# Install only production dependencies +RUN npm ci --only=production --no-audit --no-fund && \ + npm cache clean --force + +# Copy built application from builder stage +COPY --from=builder /app/dist ./dist + +# Copy necessary data and configuration files +COPY data/ ./data/ +COPY src/database/schema-optimized.sql ./src/database/schema-optimized.sql +COPY .env.example ./ + +# Create data directory if it doesn't exist and set permissions +RUN mkdir -p ./data && \ + chmod 755 ./data + +# Add metadata labels +LABEL org.opencontainers.image.source="https://github.com/czlonkowski/n8n-mcp" +LABEL org.opencontainers.image.description="n8n MCP Server - Integration between n8n workflow automation and Model Context Protocol" +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.title="n8n-mcp" +LABEL org.opencontainers.image.version="2.7.13" + +# Create non-root user for security +RUN addgroup -g 1001 -S nodejs && \ + adduser -S nodejs -u 1001 && \ + chown -R nodejs:nodejs /app +USER nodejs + +# Set environment variables +ENV NODE_ENV=production +ENV IS_DOCKER=true +ENV MCP_MODE=http +ENV USE_FIXED_HTTP=true + +# Expose port (Railway will set PORT automatically) +EXPOSE 3000 + +# Health check +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD curl -f http://127.0.0.1:${PORT:-3000}/health || exit 1 + +# Start the application in HTTP mode +CMD ["node", "dist/mcp/index.js", "--http"] diff --git a/README.md b/README.md index 54b232e..cd6d594 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ A Model Context Protocol (MCP) server that provides AI assistants with comprehensive access to n8n node documentation, properties, and operations. Deploy in minutes to give Claude and other AI assistants deep knowledge about n8n's 525+ workflow automation nodes. +[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template?sourceUrl=https://github.com/czlonkowski/n8n-mcp) + + ## Overview n8n-MCP serves as a bridge between n8n's workflow automation platform and AI models, enabling them to understand and work with n8n nodes effectively. It provides structured access to: diff --git a/railway.json b/railway.json new file mode 100644 index 0000000..e9ec6bd --- /dev/null +++ b/railway.json @@ -0,0 +1,10 @@ +{ + "name": "n8n-mcp", + "services": [ + { + "name": "n8n-mcp", + "source": ".", + "dockerfilePath": "Dockerfile.railway" + } + ] +}