Hello, on version 0.x I have used the following scheme using docker:
FROM n8nio/n8n
RUN apk add --update python3 py3-pip
# installs requests library
RUN python3 -m pip install requests
# upgrades pip (not necessary)
RUN python3 -m pip install --upgrade pip
On 1.x it doesn't work. Does anyone have a clue how to add python and some libraries to 1.x docker?
Regards,
Maciej
You will need to specify ârootâ as the user before installing/updating packages.
This should work:
FROM n8nio/n8n:latest
USER root
WORKDIR /data
RUN apk add --update --no-cache python3 curl
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools
Starting with n8n release 1, n8n runs under the ânodeâ user for security purposes. Make sure to specify the ânodeâ user in your docker-compose.yaml file for n8n.
docker-compose.yaml should look similar to this:
version: '3.8'
services:
n8n:
image: n8n-python # the image you built with your Dockerfile
user: "node" # specify 'node' as the user running the n8n app
restart: unless-stopped
container_name: n8n-python
environment:
GENERIC_TIMEZONE: ${TIMEZONE}
TZ: ${TIMEZONE}
ports:
- "5678:5678"
volumes:
- ./n8n_data:/home/node/.n8n
- ./local-files:/data/files # by default workdir == /data
- ./python_scripts:/data/py_scripts
- ./requirements.txt:/data/requirements.txt
Also, donât forget to declare TIMEZONE (along with other variables) in your .env file.
[5/6] RUN pip3 install --no-cache --upgrade pip setuptool:
0.998 Requirement already satisfied: pip in /usr/lib/python3.11/site-packages (23.2.1)
1.468 ERROR: Could not find a version that satisfies the requirement setuptool (from versions: none)
1.468 ERROR: No matching distribution found for setuptool
Dockerfile:7
5 | RUN apk add --update --no-cache python3 curl
6 | RUN python3 -m ensurepip
7 | >>> RUN pip3 install --no-cache --upgrade pip setuptool
8 | RUN python3 -m pip install phonenumbers
9
ERROR: failed to solve: process â/bin/sh -c pip3 install --no-cache --upgrade pip setuptoolâ did not complete successfully: exit code: 1