-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
131 lines (125 loc) · 5.38 KB
/
docker-compose.yml
File metadata and controls
131 lines (125 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
services:
builder:
image: node:18-alpine
container_name: n8n-upstage-builder
working_dir: /workspace
volumes:
- .:/workspace
command: >
sh -c "
# Skip builder in production mode
if [ \"$${NODE_MODE:-dev}\" = \"prod\" ]; then
echo '[Builder] Production mode detected, skipping build.'
exit 0
fi
build() {
echo '[Builder] Building...'
npm ci
npm run build
echo '[Builder] Build completed successfully!'
}
save_hash() {
if command -v md5sum >/dev/null 2>&1; then
HASH=$$(find src package.json tsconfig.json -type f 2>/dev/null | sort | xargs md5sum 2>/dev/null | md5sum 2>/dev/null | cut -d' ' -f1 2>/dev/null || echo '')
if [ -n \"$$HASH\" ]; then
echo \"$$HASH\" > dist/.build-hash 2>/dev/null || true
fi
fi
}
# Check if dist/index.js exists (required file)
if [ ! -f dist/index.js ]; then
build
save_hash
exit 0
fi
# Compare source file hash with last build hash
NEEDS_REBUILD=false
if command -v md5sum >/dev/null 2>&1 && [ -f dist/.build-hash ]; then
CURRENT_HASH=$$(find src package.json tsconfig.json -type f 2>/dev/null | sort | xargs md5sum 2>/dev/null | md5sum 2>/dev/null | cut -d' ' -f1 2>/dev/null || echo '')
LAST_HASH=$$(cat dist/.build-hash 2>/dev/null || echo '')
if [ -n \"$$CURRENT_HASH\" ] && [ \"$$CURRENT_HASH\" != \"$$LAST_HASH\" ]; then
NEEDS_REBUILD=true
fi
else
# Fallback: check if package.json or tsconfig.json is newer than dist/index.js
if [ package.json -nt dist/index.js ] 2>/dev/null || [ tsconfig.json -nt dist/index.js ] 2>/dev/null; then
NEEDS_REBUILD=true
fi
fi
if [ \"$$NEEDS_REBUILD\" = \"true\" ]; then
build
save_hash
else
echo '[Builder] Dist files are up to date, skipping build.'
fi
"
restart: "no"
environment:
- NODE_MODE=${NODE_MODE:-dev}
n8n:
image: n8nio/n8n:latest
container_name: n8n-upstage
# Builder dependency: builder will skip in prod mode automatically
depends_on:
builder:
condition: service_completed_successfully
ports:
- "5678:5678"
volumes:
- ./n8n_data:/home/node/.n8n
# Local development volumes (only used when NODE_MODE=dev)
- ./dist:/tmp/n8n-nodes-upstage/dist:ro
- ./package.json:/tmp/n8n-nodes-upstage/package.json:ro
# Pre-built node_modules for dev mode (avoids npm install issues with peer deps)
- ./node_modules:/tmp/n8n-nodes-upstage/node_modules:ro
environment:
- N8N_COMMUNITY_NODES_ENABLED=true
- N8N_CUSTOM_EXTENSIONS=/home/node/.n8n/custom
# Mode: 'dev' for local development, 'prod' for npm package
- NODE_MODE=${NODE_MODE:-dev}
# Performance and deprecation fixes
- DB_SQLITE_POOL_SIZE=10
- N8N_RUNNERS_ENABLED=true
# Security settings (more secure defaults)
- N8N_BLOCK_ENV_ACCESS_IN_NODE=true
- N8N_GIT_NODE_DISABLE_BARE_REPOS=true
# Fix file permissions warning
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
entrypoint: >
sh -c "
if [ \"$$NODE_MODE\" = \"prod\" ]; then
echo '[upstage] Production mode: Installing latest n8n-nodes-upstage from npm...'
mkdir -p /home/node/.n8n/custom
cd /home/node/.n8n/custom
# Always install the latest version from npm registry
if [ ! -f package.json ]; then
npm init -y
fi
# Remove existing installation to ensure fresh install of latest version
if [ -d node_modules/n8n-nodes-upstage ]; then
echo '[upstage] Removing existing installation to ensure latest version...'
rm -rf node_modules/n8n-nodes-upstage
fi
# Install latest version explicitly
echo '[upstage] Installing latest n8n-nodes-upstage from npm registry...'
npm install n8n-nodes-upstage@latest --legacy-peer-deps --save
echo '[upstage] Latest n8n-nodes-upstage installed successfully!'
else
echo '[upstage] Development mode: Using local n8n-nodes-upstage...'
if [ ! -f /home/node/.n8n/custom/package.json ] || [ /tmp/n8n-nodes-upstage/package.json -nt /home/node/.n8n/custom/package.json ] || [ \"$$(find /tmp/n8n-nodes-upstage/dist -type f -name '*.js' -newer /home/node/.n8n/custom/package.json 2>/dev/null | head -1)\" != \"\" ]; then
echo '[upstage] Installing/Updating local n8n-nodes-upstage...'
mkdir -p /home/node/.n8n/custom
rm -rf /home/node/.n8n/custom/*
# Copy dist and package.json
cp -r /tmp/n8n-nodes-upstage/dist /home/node/.n8n/custom/
cp /tmp/n8n-nodes-upstage/package.json /home/node/.n8n/custom/
# Symlink pre-built node_modules from host (avoids npm install peer dep issues)
ln -s /tmp/n8n-nodes-upstage/node_modules /home/node/.n8n/custom/node_modules
echo '[upstage] Local n8n-nodes-upstage installed successfully!'
else
echo '[upstage] Local n8n-nodes-upstage is up to date, skipping reinstall.'
fi
fi
exec n8n start
"
restart: unless-stopped