FROM n8nio/n8n:2.22.1

# Pre-install community node as bootstrap.
# NOTE: at runtime the PVC mounts over /home/node/.n8n, so n8n uses the
# version from the PVC. This installation acts as a fallback if the PVC
# is ever lost or a fresh volume is used.
USER root

RUN mkdir -p /home/node/.n8n/nodes && \
    cd /home/node/.n8n/nodes && \
    echo '{"name":"installed-nodes","private":true,"dependencies":{}}' > package.json && \
    npm install n8n-nodes-upload-post@0.1.42 && \
    chown -R node:node /home/node/.n8n

USER node
