Files
n8n-mcp/docker/docker-entrypoint.sh
czlonkowski 4ef03da245 fix: resolve Docker build failures in GitHub Actions
- Added ca-certificates package for proper SSL certificate validation
- Configured git to handle SSL and initialization properly
- Added --depth 1 for faster cloning and reduced network issues
- Improved error handling to continue build even if docs clone fails
- Fixed su-exec issue by using Alpine's native su command
- Redirected git clone stderr to avoid polluting build logs

These changes address the exit code 128 git errors occurring in GitHub Actions
Docker builds while maintaining backwards compatibility.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-16 00:54:30 +02:00

41 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
set -e
# Environment variable validation
if [ "$MCP_MODE" = "http" ] && [ -z "$AUTH_TOKEN" ]; then
echo "ERROR: AUTH_TOKEN is required for HTTP mode"
exit 1
fi
# Database initialization with file locking to prevent race conditions
if [ ! -f "/app/data/nodes.db" ]; then
echo "Database not found. Initializing..."
# Use a lock file to prevent multiple containers from initializing simultaneously
(
flock -x 200
# Double-check inside the lock
if [ ! -f "/app/data/nodes.db" ]; then
echo "Initializing database..."
cd /app && node dist/scripts/rebuild.js || {
echo "ERROR: Database initialization failed"
exit 1
}
fi
) 200>/app/data/.db.lock
fi
# Fix permissions if running as root (for development)
if [ "$(id -u)" = "0" ]; then
echo "Running as root, fixing permissions..."
chown -R nodejs:nodejs /app/data
# Switch to nodejs user (using Alpine's native su)
exec su nodejs -c "$*"
fi
# Trap signals for graceful shutdown
trap 'echo "Shutting down..."; kill -TERM $PID' TERM INT
# Execute the main command in background
"$@" &
PID=$!
wait $PID