fix: resolve Docker port configuration mismatch (Issue #228) (#373)

This commit is contained in:
Romuald Członkowski
2025-10-25 23:56:54 +02:00
committed by GitHub
parent ee7229b4db
commit 590dc087ac
7 changed files with 46 additions and 13 deletions

View File

@@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [2.22.6] - 2025-10-25
### 🐛 Bug Fixes
**Issue #228: Fix Docker Port Configuration Mismatch**
Fixed critical Docker configuration bug where custom PORT environment variable values were not properly mapped to container ports, causing connection failures in Docker deployments.
#### Problem
- **docker-compose.yml**: Port mapping `"${PORT:-3000}:3000"` hardcoded container port to 3000
- **docker-compose.yml**: Health check hardcoded to port 3000
- **Dockerfile**: Health check hardcoded to port 3000
- Impact: When PORT≠3000 (e.g., PORT=8080), Docker mapped host port to wrong container port
#### Solution
- **docker-compose.yml line 44**: Changed port mapping to `"${PORT:-3000}:${PORT:-3000}"`
- **docker-compose.yml line 56**: Updated health check to use dynamic port `$${PORT:-3000}`
- **Dockerfile line 93**: Updated HEALTHCHECK to use dynamic port `${PORT:-3000}`
- **Dockerfile line 85**: Added clarifying comment about PORT configurability
#### Testing
- Verified with default PORT (3000)
- Verified with custom PORT (8080)
- Health checks work correctly in both scenarios
#### Related Issues
- Fixes #228 (Docker Compose port error)
- Likely fixes #109 (Configuration ignored in HTTP mode)
- Likely fixes #84 (Can't access container)
Conceived by Romuald Członkowski - [www.aiadvisors.pl/en](https://www.aiadvisors.pl/en)
## [2.22.3] - 2025-10-25 ## [2.22.3] - 2025-10-25
### 🔧 Code Quality Improvements ### 🔧 Code Quality Improvements

View File

@@ -82,7 +82,7 @@ ENV IS_DOCKER=true
# To opt-out, uncomment the following line: # To opt-out, uncomment the following line:
# ENV N8N_MCP_TELEMETRY_DISABLED=true # ENV N8N_MCP_TELEMETRY_DISABLED=true
# Expose HTTP port # Expose HTTP port (default 3000, configurable via PORT environment variable at runtime)
EXPOSE 3000 EXPOSE 3000
# Set stop signal to SIGTERM (default, but explicit is better) # Set stop signal to SIGTERM (default, but explicit is better)
@@ -90,7 +90,7 @@ STOPSIGNAL SIGTERM
# Health check # Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://127.0.0.1:3000/health || exit 1 CMD sh -c 'curl -f http://127.0.0.1:${PORT:-3000}/health || exit 1'
# Optimized entrypoint # Optimized entrypoint
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

View File

@@ -20,19 +20,19 @@ services:
image: n8n-mcp:latest image: n8n-mcp:latest
container_name: n8n-mcp container_name: n8n-mcp
ports: ports:
- "3000:3000" - "${PORT:-3000}:${PORT:-3000}"
environment: environment:
- MCP_MODE=${MCP_MODE:-http} - MCP_MODE=${MCP_MODE:-http}
- AUTH_TOKEN=${AUTH_TOKEN} - AUTH_TOKEN=${AUTH_TOKEN}
- NODE_ENV=${NODE_ENV:-production} - NODE_ENV=${NODE_ENV:-production}
- LOG_LEVEL=${LOG_LEVEL:-info} - LOG_LEVEL=${LOG_LEVEL:-info}
- PORT=3000 - PORT=${PORT:-3000}
volumes: volumes:
# Mount data directory for persistence # Mount data directory for persistence
- ./data:/app/data - ./data:/app/data
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"] test: ["CMD", "sh", "-c", "curl -f http://localhost:$${PORT:-3000}/health"]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 3 retries: 3

View File

@@ -37,11 +37,12 @@ services:
container_name: n8n-mcp container_name: n8n-mcp
restart: unless-stopped restart: unless-stopped
ports: ports:
- "${MCP_PORT:-3000}:3000" - "${MCP_PORT:-3000}:${MCP_PORT:-3000}"
environment: environment:
- NODE_ENV=production - NODE_ENV=production
- N8N_MODE=true - N8N_MODE=true
- MCP_MODE=http - MCP_MODE=http
- PORT=${MCP_PORT:-3000}
- N8N_API_URL=http://n8n:5678 - N8N_API_URL=http://n8n:5678
- N8N_API_KEY=${N8N_API_KEY} - N8N_API_KEY=${N8N_API_KEY}
- MCP_AUTH_TOKEN=${MCP_AUTH_TOKEN} - MCP_AUTH_TOKEN=${MCP_AUTH_TOKEN}
@@ -56,7 +57,7 @@ services:
n8n: n8n:
condition: service_healthy condition: service_healthy
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"] test: ["CMD", "sh", "-c", "curl -f http://localhost:$${MCP_PORT:-3000}/health"]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 3 retries: 3

View File

@@ -41,7 +41,7 @@ services:
# Port mapping # Port mapping
ports: ports:
- "${PORT:-3000}:3000" - "${PORT:-3000}:${PORT:-3000}"
# Resource limits # Resource limits
deploy: deploy:
@@ -53,7 +53,7 @@ services:
# Health check # Health check
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:3000/health"] test: ["CMD", "sh", "-c", "curl -f http://127.0.0.1:$${PORT:-3000}/health"]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 3 retries: 3

View File

@@ -59,10 +59,10 @@ docker compose up -d
- n8n-mcp-data:/app/data - n8n-mcp-data:/app/data
ports: ports:
- "${PORT:-3000}:3000" - "${PORT:-3000}:${PORT:-3000}"
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:3000/health"] test: ["CMD", "sh", "-c", "curl -f http://127.0.0.1:$${PORT:-3000}/health"]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 3 retries: 3

View File

@@ -1,6 +1,6 @@
{ {
"name": "n8n-mcp", "name": "n8n-mcp",
"version": "2.22.5", "version": "2.22.6",
"description": "Integration between n8n workflow automation and Model Context Protocol (MCP)", "description": "Integration between n8n workflow automation and Model Context Protocol (MCP)",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",