| |
| FROM postgres:latest |
|
|
| |
| ARG POSTGRES_USER |
| ARG POSTGRES_PASSWORD |
| ARG POSTGRES_DB |
| ARG WEBHOOK_URL |
| ARG requirements |
| ARG WORKDIR |
| ARG NODEJS_VER |
|
|
| |
| ENV N8N_HOST=0.0.0.0 |
| ENV N8N_PORT=7860 |
| ENV N8N_PROTOCOL=https |
| ENV WEBHOOK_URL=${WEBHOOK_URL:-https://aigenai-db.hf.space/} |
| ENV GENERIC_TIMEZONE=Asia/Shanghai |
| ENV N8N_METRICS=true |
| ENV QUEUE_HEALTH_CHECK_ACTIVE=true |
| ENV N8N_PAYLOAD_SIZE_MAX=256 |
| |
| ENV DB_TYPE=postgresdb |
| ENV DB_POSTGRESDB_HOST=localhost |
| ENV DB_POSTGRESDB_PORT=5432 |
| ENV DB_POSTGRESDB_USER=${POSTGRES_USER:-n8n} |
| ENV DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD:-n8n} |
| ENV DB_POSTGRESDB_DATABASE=${POSTGRES_DB:-n8n} |
| |
| ENV VIRTUAL_ENV=/opt/venv |
| ENV PATH="$VIRTUAL_ENV/bin:$PATH" |
|
|
| |
| COPY run.sh ${WORKDIR:-/app}/run.sh |
|
|
| |
| USER root |
|
|
| |
| RUN chmod +x ${WORKDIR:-/app}/run.sh |
|
|
| |
| 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 && \ |
| ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ |
| dpkg-reconfigure --frontend noninteractive tzdata && \ |
|
|
| |
| curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip && \ |
| unzip rclone-current-linux-amd64.zip && cd rclone-*-linux-amd64 && cp rclone /usr/bin/ && \ |
| chown ${USER}:${USER} /usr/bin/rclone && chmod 755 /usr/bin/rclone && \ |
|
|
| |
| curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ |
| apt-get install -y nodejs && \ |
| npm install -g n8n && \ |
| apt-get clean && rm -rf /var/lib/apt/lists/* && \ |
|
|
| |
| python3 -m venv $VIRTUAL_ENV && \ |
| $VIRTUAL_ENV/bin/pip install --upgrade pip && \ |
| $VIRTUAL_ENV/bin/pip install ${requirements:-requests} && \ |
|
|
| |
| usermod -u 1000 postgres && groupmod -g 1000 postgres && \ |
|
|
| |
| chown -R postgres:postgres /var/lib/postgresql && \ |
| chown -R postgres:postgres /var/run/postgresql |
|
|
| |
| USER postgres |
|
|
| |
| RUN initdb -D /var/lib/postgresql/data && \ |
| pg_ctl start -D /var/lib/postgresql/data && \ |
| psql --command "CREATE ROLE $POSTGRES_USER WITH LOGIN SUPERUSER PASSWORD '$POSTGRES_PASSWORD';" && \ |
| createdb -O $POSTGRES_USER $POSTGRES_DB && \ |
| pg_ctl stop -D /var/lib/postgresql/data |
|
|
| |
| WORKDIR ${WORKDIR:-/app} |
|
|
| |
| CMD ["./run.sh"] |
|
|
| |
| HEALTHCHECK --interval=120s --timeout=10s --start-period=10s --retries=3 \ |
| CMD curl -f http://localhost:7860/HEALTHZ || exit 1 |
|
|