|
|
|
FROM nikolaik/python-nodejs:python3.12-nodejs20 |
|
|
|
|
|
LABEL maintainer="ai来事 <https://www.youtube.com/@all.ai.>" |
|
|
|
ARG CACHEBUST=1 |
|
|
|
|
|
ARG WEBHOOK_URL=https://你的hf账户名-空间名.hf.space/ |
|
ARG POSTGRESDB_PORT=5432 |
|
|
|
|
|
ENV WEBHOOK_URL=${WEBHOOK_URL} \ |
|
N8N_HOST=0.0.0.0 \ |
|
N8N_PORT=7860 \ |
|
N8N_PROTOCOL=https \ |
|
GENERIC_TIMEZONE=Asia/Shanghai \ |
|
N8N_METRICS=true \ |
|
QUEUE_HEALTH_CHECK_ACTIVE=true \ |
|
N8N_PAYLOAD_SIZE_MAX=256 \ |
|
DB_TYPE=postgresdb \ |
|
DB_POSTGRESDB_PORT=${POSTGRESDB_PORT} \ |
|
VIRTUAL_ENV=/home/pn/venv \ |
|
PATH="/home/pn/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH" \ |
|
|
|
QUEUE_BULL_REDIS_HOST=localhost \ |
|
QUEUE_BULL_REDIS_PORT=6379 \ |
|
QUEUE_BULL_REDIS_DB=0 \ |
|
N8N_QUEUE_BULL_REDIS_PREFIX=n8n:queue \ |
|
EXECUTIONS_MODE=queue |
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \ |
|
curl \ |
|
unzip \ |
|
gnupg \ |
|
build-essential \ |
|
sudo \ |
|
vim \ |
|
git \ |
|
procps \ |
|
lsof \ |
|
net-tools \ |
|
ca-certificates \ |
|
openssl \ |
|
tzdata \ |
|
htop \ |
|
jq \ |
|
netcat-openbsd \ |
|
|
|
redis-server \ |
|
&& ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ |
|
&& dpkg-reconfigure --frontend noninteractive tzdata \ |
|
&& apt-get clean \ |
|
&& rm -rf /var/lib/apt/lists/* \ |
|
|
|
&& python3 -m venv $VIRTUAL_ENV \ |
|
&& $VIRTUAL_ENV/bin/pip install --no-cache-dir --upgrade pip requests yt-dlp \ |
|
|
|
&& npm install -g n8n@latest pnpm \ |
|
&& npm cache clean --force |
|
|
|
|
|
RUN --mount=type=secret,id=POSTGRES_USER,mode=0444,required=true \ |
|
--mount=type=secret,id=POSTGRES_PASSWORD,mode=0444,required=true \ |
|
--mount=type=secret,id=POSTGRES_DB,mode=0444,required=true \ |
|
--mount=type=secret,id=POSTGRESDB_HOST,mode=0444,required=true \ |
|
echo "export DB_POSTGRESDB_HOST=$(cat /run/secrets/POSTGRESDB_HOST)" >> /home/pn/.env && \ |
|
echo "export DB_POSTGRESDB_USER=$(cat /run/secrets/POSTGRES_USER)" >> /home/pn/.env && \ |
|
echo "export DB_POSTGRESDB_PASSWORD=$(cat /run/secrets/POSTGRES_PASSWORD)" >> /home/pn/.env && \ |
|
echo "export DB_POSTGRESDB_DATABASE=$(cat /run/secrets/POSTGRES_DB)" >> /home/pn/.env && \ |
|
chown pn:pn /home/pn/.env |
|
|
|
|
|
WORKDIR /home/pn/n8n |
|
|
|
|
|
COPY --chown=pn:pn run.sh ./run.sh |
|
RUN chmod +x ./run.sh \ |
|
&& mkdir -p /home/pn/.n8n \ |
|
&& chown -R pn:pn /home/pn/.n8n |
|
|
|
|
|
EXPOSE 7860 |
|
|
|
|
|
USER pn |
|
|
|
|
|
VOLUME ["/home/pn/.n8n"] |
|
|
|
|
|
CMD ["./run.sh"] |