aiflow / Dockerfile
hijnu's picture
Update Dockerfile
ba17c91 verified
# 使用 PostgreSQL 作为基础镜像
FROM postgres:15
# 主要变量,确保为你实际的值,可在HF设置中设置的值
ARG WEBHOOK_URL=https://你的hf账户名-空间名.hf.space/
ARG WEBDAV_URL="https://cfr2.n8n.us.kg/"
ARG WEBDAV_USER="your_username"
ARG WEBDAV_PASSWORD="your_password"
# 一般变量,使用默认即可,可在HF设置中设置的值
ARG POSTGRES_USER=n8n
ARG POSTGRES_PASSWORD=n8n
ARG POSTGRES_DB=n8n
ARG WORKDIR=/app
ARG DB_IMPORT=yes
ARG NODEJS_VER=20
# 设置环境变量,使用默认即可。
ENV POSTGRES_USER=${POSTGRES_USER} \
POSTGRES_PASSWORD=${POSTGRES_PASSWORD} \
POSTGRES_DB=${POSTGRES_DB} \
WEBHOOK_URL=${WEBHOOK_URL} \
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=$WORKDIR/venv \
WEBDAV_URL=${WEBDAV_URL} \
WEBDAV_USER=${WEBDAV_USER} \
WEBDAV_PASSWORD=${WEBDAV_PASSWORD} \
WORKDIR=${WORKDIR} \
PATH="$WORKDIR/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
COPY requirements.txt ${WORKDIR}/requirements.txt
COPY package.txt ${WORKDIR}/package.txt
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 python3-venv python3-pip gosu \
htop jq && \
curl -fsSL https://deb.nodesource.com/setup_${NODEJS_VER}.x | bash - && \
apt-get install -y nodejs && \
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 --upgrade pip && \
$VIRTUAL_ENV/bin/pip install -r ${WORKDIR}/requirements.txt && \
npm install -g $(cat ${WORKDIR}/package.txt)
WORKDIR ${WORKDIR}
COPY run.sh ${WORKDIR}/run.sh
COPY import-db.sh ${WORKDIR}/import-db.sh
COPY backup.sh ${WORKDIR}/backup.sh
RUN chmod +x ${WORKDIR}/run.sh ${WORKDIR}/import-db.sh ${WORKDIR}/backup.sh
USER root
RUN usermod -u 1000 postgres && groupmod -g 1000 postgres && \
chown -R postgres:postgres /var/lib/postgresql /var/run/postgresql ${WORKDIR} && \
mkdir -p ${WORKDIR}/backups && chmod -R 775 ${WORKDIR}/backups
USER postgres
EXPOSE 7860
CMD ./run.sh