|
|
|
FROM postgres:latest |
|
|
|
|
|
LABEL maintainer="B站ai来事 <[email protected]>" |
|
LABEL version="2.0" |
|
LABEL description="Custom image with PostgreSQL, Node.js, and Python for n8n" |
|
|
|
|
|
ARG WORKDIR=/app |
|
ARG NODEJS_VER=20 |
|
ARG NODE_PACKAGES="n8n" |
|
ARG PYTHON_PACKAGES="requests yt-dlp" |
|
|
|
|
|
ENV POSTGRES_USER=n8n \ |
|
POSTGRES_PASSWORD=n8n \ |
|
POSTGRES_DB=n8n \ |
|
WEBHOOK_URL=https://aigenai-db.hf.space/ \ |
|
DB_IMPORT=no \ |
|
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 \ |
|
PATH="$WORKDIR/venv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
|
|
|
|
|
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 python3 python3-venv python3-pip gosu \ |
|
htop jq wget && \ |
|
curl -fsSL https://deb.nodesource.com/setup_${NODEJS_VER}.x | bash - && \ |
|
apt-get install -y nodejs && \ |
|
npm install -g ${NODE_PACKAGES} && \ |
|
curl https://rclone.org/install.sh | bash && \ |
|
ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ |
|
dpkg-reconfigure --frontend noninteractive tzdata && \ |
|
python3 -m venv $VIRTUAL_ENV && \ |
|
$VIRTUAL_ENV/bin/pip install --no-cache-dir --upgrade pip && \ |
|
$VIRTUAL_ENV/bin/pip install --no-cache-dir ${PYTHON_PACKAGES} && \ |
|
apt-get clean && \ |
|
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ |
|
npm cache clean --force |
|
|
|
|
|
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 |
|
|
|
|
|
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 |
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ |
|
CMD pg_isready && curl -f http://localhost:7860/HEALTHZ || exit 1 |
|
|
|
|
|
CMD ["./run.sh"] |