-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.dev
More file actions
49 lines (40 loc) · 1.9 KB
/
Copy pathDockerfile.dev
File metadata and controls
49 lines (40 loc) · 1.9 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
FROM n8nio/n8n:latest AS base-dev
# Accept a tarball build-arg pointing to a tar produced by `pnpm pack`
ARG PLUGIN_TARBALL
USER root
WORKDIR /tmp/plugin
# This Dockerfile supports two final targets:
# - final: default dev image without plugin installed
# - final-plugin: dev image with plugin installed (requires building with --target final-plugin and --build-arg PLUGIN_TARBALL=...)
FROM node:24.12-bookworm-slim AS plugin-builder-dev
ARG PLUGIN_TARBALL
WORKDIR /tmp
# Copy the tarball into the builder stage. This COPY will fail if you ask to
# build the plugin target but don't provide PLUGIN_TARBALL; for normal no-plugin
# builds you should not use the final-plugin target.
COPY ${PLUGIN_TARBALL} /tmp/plugin.tgz
RUN mkdir -p /opt/plugins && mkdir -p /tmp/plugin && cd /tmp && printf "{}" > package.json && corepack enable && pnpm add /tmp/plugin.tgz --ignore-scripts --config.node-linker=hoisted && \
# copy node_modules entries into /opt/plugins so runtime can use them
PKG_DIR=$(node -p "Object.keys(require('./package.json').dependencies||{})[0]") || true; \
if [ -d "node_modules" ]; then \
mkdir -p /opt/plugins/node_modules; \
cp -a node_modules/. /opt/plugins/node_modules/; \
fi; \
chown -R root:root /opt/plugins && rm -f /tmp/plugin.tgz || true
FROM base-dev AS final
USER root
RUN mkdir -p /home/node/.n8n/custom && chown -R node:node /home/node/.n8n || true
ENV N8N_CUSTOM_EXTENSIONS=/home/node/.n8n/custom
USER node
FROM base-dev AS final-plugin
USER root
# Copy prepared /opt/plugins from plugin-builder-dev
COPY --from=plugin-builder-dev /opt/plugins /opt/plugins
RUN mkdir -p /home/node/.n8n/custom && \
if [ -d "/opt/plugins/node_modules/n8n-nodes-the-bluesky" ]; then \
cp -a /opt/plugins/node_modules/n8n-nodes-the-bluesky /home/node/.n8n/custom/; \
fi && \
chown -R node:node /home/node/.n8n || true
ENV N8N_CUSTOM_EXTENSIONS=/home/node/.n8n/custom
ENV NODE_PATH="/opt/plugins/node_modules"
USER node