-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile
More file actions
125 lines (108 loc) · 4.53 KB
/
Containerfile
File metadata and controls
125 lines (108 loc) · 4.53 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
# --------------------------------------------------------------------------
# THIS FILE IS AUTOGENERATED - DO NOT EDIT MANUALLY
#
# Source: Containerfile.j2
# --------------------------------------------------------------------------
ARG BASE_VERSION=15
ARG NODE_VERSION=22
ARG PYTHON_VERSION=313
FROM ghcr.io/daemonless/base:${BASE_VERSION} AS builder
ARG NODE_VERSION
ARG PYTHON_VERSION
# Install Node.js and build dependencies for native modules
RUN pkg update && \
pkg install -y \
FreeBSD-clang \
FreeBSD-clibs-dev \
FreeBSD-openssl-dev \
FreeBSD-zlib-dev \
binutils \
coreutils \
node${NODE_VERSION} \
npm-node${NODE_VERSION} \
python${PYTHON_VERSION} \
gmake \
git \
sqlite3 \
ca_root_nss && \
pkg clean -ay && \
rm -rf /var/cache/pkg/* /var/db/pkg/repos/* && \
ln -sf /usr/local/bin/python3.13 /usr/local/bin/python3 && \
ln -sf /usr/local/bin/python3.13 /usr/local/bin/python
# Install n8n globally and capture version
RUN npm install -g n8n && \
npm cache clean --force && \
mkdir -p /app && npm list -g n8n --depth=0 | grep n8n | sed 's/.*@//' > /app/version
# Set up Python task runner at the path n8n expects
RUN mkdir -p /usr/local/lib/node_modules/@n8n && \
cd /usr/local/lib/node_modules/@n8n && \
git clone --depth 1 https://github.com/n8n-io/n8n.git n8n-src && \
mv n8n-src/packages/@n8n/task-runner-python . && \
rm -rf n8n-src && \
cd task-runner-python && \
python3 -m venv .venv && \
.venv/bin/python -m ensurepip --upgrade && \
.venv/bin/pip install --no-cache-dir "websockets>=15.0.1"
# Production image
FROM ghcr.io/daemonless/base:${BASE_VERSION}
ARG FREEBSD_ARCH=amd64
ARG NODE_VERSION
ARG PYTHON_VERSION
ARG PACKAGES="node${NODE_VERSION} sqlite3 git ca_root_nss GraphicsMagick icu python${PYTHON_VERSION}"
ARG UPSTREAM_URL="https://registry.npmjs.org/n8n/latest"
ARG UPSTREAM_JQ=".version"
ARG HEALTHCHECK_ENDPOINT="http://localhost:5678/healthz"
ENV HEALTHCHECK_URL="${HEALTHCHECK_ENDPOINT}"
# --- Metadata (Injected by Generator) ---
LABEL org.opencontainers.image.title="n8n" \
org.opencontainers.image.description="Fair-code workflow automation platform with native AI capabilities — combine visual building with custom code and 400+ integrations." \
org.opencontainers.image.source="https://github.com/daemonless/n8n" \
org.opencontainers.image.url="https://n8n.io/" \
org.opencontainers.image.documentation="https://docs.n8n.io/" \
org.opencontainers.image.licenses="Sustainable-Use-1.0" \
org.opencontainers.image.vendor="daemonless" \
org.opencontainers.image.authors="daemonless" \
io.daemonless.category="Utilities" \
io.daemonless.port="5678" \
io.daemonless.volumes="/config" \
io.daemonless.arch="${FREEBSD_ARCH}" \
io.daemonless.upstream-url="${UPSTREAM_URL}" \
io.daemonless.upstream-jq="${UPSTREAM_JQ}" \
io.daemonless.healthcheck-url="${HEALTHCHECK_ENDPOINT}" \
io.daemonless.packages="${PACKAGES}"
# Install runtime dependencies
RUN pkg update && \
pkg install -y \
${PACKAGES} && \
pkg clean -ay && \
rm -rf /var/cache/pkg/* /var/db/pkg/repos/*
# Copy n8n from builder and fix permissions for non-root execution
COPY --from=builder /app/version /app/version
COPY --from=builder /usr/local/lib/node_modules /usr/local/lib/node_modules
RUN ln -sf /usr/local/lib/node_modules/n8n/bin/n8n /usr/local/bin/n8n && \
ln -sf /usr/local/bin/python3.13 /usr/local/bin/python3 && \
ln -sf /usr/local/bin/python3.13 /usr/local/bin/python && \
rm -f /usr/local/lib/node_modules/@n8n/task-runner-python/.venv/bin/python3 && \
ln -s /usr/local/bin/python3.13 /usr/local/lib/node_modules/@n8n/task-runner-python/.venv/bin/python3 && \
chmod -R o+rX /usr/local/lib/node_modules && \
find /usr/local/lib/node_modules/n8n -type d -name "sqlite" -path "*/migrations/*" | \
xargs -I{} find {} -name "*.js" | \
xargs perl -pi -e \
's{((?:WHERE|SET)\b[^=]+=\s*)"([^"]+)"}{$1'"'"'$2'"'"'}gi; s{(\bIN\s*\(\s*)"([^"]+)"}{$1'"'"'$2'"'"'}gi'
# Create config directory
RUN mkdir -p /config && \
chown -R bsd:bsd /config
# Copy service definitions and init scripts
COPY root/ /
# Make scripts executable
RUN chmod +x /etc/services.d/*/run /etc/cont-init.d/* 2>/dev/null || true
# Environment
ENV N8N_USER_FOLDER=/config \
N8N_PORT=5678 \
N8N_PROTOCOL=http \
N8N_LISTEN_ADDRESS=0.0.0.0 \
NODE_ENV=production
# --- Expose (Injected by Generator) ---
EXPOSE 5678
# --- Volumes (Injected by Generator) ---
VOLUME /config