|
|
|
FROM node:20-slim AS builder |
|
|
|
|
|
ARG requirements="requests yt-dlp" |
|
ARG PACKAGES="n8n" |
|
ARG WORKDIR=/app |
|
ARG DUMP_URL |
|
ARG DUMP_PASSWORD |
|
|
|
|
|
RUN apt-get update && apt-get install -y python3 python3-venv curl gnupg build-essential && \ |
|
npm install -g ${PACKAGES} && \ |
|
apt-get clean && rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
ENV VIRTUAL_ENV=/opt/venv |
|
RUN python3 -m venv $VIRTUAL_ENV && \ |
|
$VIRTUAL_ENV/bin/pip install --upgrade pip && \ |
|
$VIRTUAL_ENV/bin/pip install $requirements |
|
|
|
|
|
FROM postgres:latest |
|
|
|
|
|
ARG POSTGRES_USER=n8n |
|
ARG POSTGRES_PASSWORD=n8n |
|
ARG POSTGRES_DB=n8n |
|
ARG WEBHOOK_URL=https://aigenai-db.hf.space/ |
|
ARG WORKDIR=/app |
|
ARG DB_IMPORT=no |
|
ARG NODEJS_VER=20 |
|
ARG PACKAGES="n8n" |
|
|
|
|
|
ENV POSTGRES_USER=${POSTGRES_USER} \ |
|
POSTGRES_PASSWORD=${POSTGRES_PASSWORD} \ |
|
POSTGRES_DB=${POSTGRES_DB} \ |
|
WEBHOOK_URL=${WEBHOOK_URL} \ |
|
WORKDIR=${WORKDIR} \ |
|
DB_IMPORT=${DB_IMPORT} \ |
|
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_HOST=localhost \ |
|
DB_POSTGRESDB_PORT=5432 \ |
|
DB_POSTGRESDB_USER=${POSTGRES_USER} \ |
|
DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD} \ |
|
DB_POSTGRESDB_DATABASE=${POSTGRES_DB} \ |
|
VIRTUAL_ENV=/opt/venv \ |
|
PATH="$VIRTUAL_ENV/bin:/usr/local/lib/node_modules/n8n/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH" |
|
|
|
|
|
COPY --from=builder /usr/local/bin/node /usr/local/bin/ |
|
COPY --from=builder /usr/local/lib/node_modules /usr/local/lib/node_modules |
|
|
|
COPY --from=builder $VIRTUAL_ENV $VIRTUAL_ENV |
|
|
|
|
|
RUN apt-get update && apt-get install -y \ |
|
curl unzip gnupg build-essential sudo vim git procps lsof net-tools \ |
|
ca-certificates openssl tzdata python3-venv gosu \ |
|
htop jq wget && \ |
|
ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ |
|
dpkg-reconfigure --frontend noninteractive tzdata |
|
|
|
|
|
RUN curl https://rclone.org/install.sh | bash |
|
|
|
|
|
WORKDIR ${WORKDIR} |
|
COPY run.sh ${WORKDIR}/run.sh |
|
COPY import-db.sh /docker-entrypoint-initdb.d/ |
|
RUN chmod +x ${WORKDIR}/run.sh /docker-entrypoint-initdb.d/import-db.sh |
|
|
|
|
|
USER root |
|
RUN usermod -u 1000 postgres && groupmod -g 1000 postgres && \ |
|
chown -R postgres:postgres /var/lib/postgresql && chown -R postgres:postgres /var/run/postgresql && \ |
|
chown -R postgres:postgres $WORKDIR && mkdir -p $WORKDIR/backups && chmod -R 775 $WORKDIR/backups |
|
|
|
|
|
USER postgres |
|
|
|
|
|
HEALTHCHECK --interval=120s --timeout=10s --start-period=10s --retries=3 \ |
|
CMD curl -f http://localhost:7860/HEALTHZ || exit 1 |
|
|
|
|
|
CMD ["./run.sh"] |