Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +27 -8
Dockerfile
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
FROM ubuntu:22.04
|
| 2 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 3 |
|
|
|
|
| 4 |
RUN apt-get update && \
|
| 5 |
apt-get install -y --no-install-recommends \
|
| 6 |
-
git python3 python3-pip python3-dev \
|
| 7 |
imagemagick fonts-liberation gnupg \
|
| 8 |
libpq-dev default-libmysqlclient-dev pkg-config \
|
| 9 |
libmagic-dev libzbar0 poppler-utils \
|
|
@@ -11,34 +12,42 @@ RUN apt-get update && \
|
|
| 11 |
pngquant zlib1g tesseract-ocr tesseract-ocr-eng \
|
| 12 |
build-essential python3-setuptools python3-wheel \
|
| 13 |
redis-server postgresql postgresql-client \
|
| 14 |
-
|
| 15 |
rm -rf /var/lib/apt/lists/*
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
RUN curl -sSf https://astral.sh/uv/install.sh | bash
|
| 18 |
|
|
|
|
| 19 |
RUN adduser --system --home /opt/paperless --group paperless
|
| 20 |
WORKDIR /opt/paperless
|
| 21 |
RUN git config --global --add safe.directory /opt/paperless
|
| 22 |
|
|
|
|
| 23 |
RUN git clone https://github.com/paperless-ngx/paperless-ngx.git . && \
|
| 24 |
git checkout v2.17.1
|
| 25 |
|
| 26 |
-
# Build
|
| 27 |
-
|
|
|
|
| 28 |
|
| 29 |
-
# Python dependencies
|
| 30 |
RUN /root/.cargo/bin/uv pip install -r requirements.txt
|
| 31 |
|
| 32 |
-
# Initialize
|
| 33 |
RUN service postgresql start && \
|
| 34 |
su - postgres -c "psql -c \"CREATE USER paperless WITH PASSWORD 'your_db_password';\"" && \
|
| 35 |
su - postgres -c "psql -c \"CREATE DATABASE paperless OWNER paperless;\"" && \
|
| 36 |
service postgresql stop
|
| 37 |
|
| 38 |
-
#
|
| 39 |
RUN mkdir -p media data consume export && \
|
| 40 |
chown -R paperless:paperless media data consume export
|
| 41 |
|
|
|
|
| 42 |
ENV PAPERLESS_REDIS="redis://localhost:6379/0" \
|
| 43 |
PAPERLESS_DBENGINE="postgresql" \
|
| 44 |
PAPERLESS_DBHOST="localhost" \
|
|
@@ -56,6 +65,7 @@ ENV PAPERLESS_REDIS="redis://localhost:6379/0" \
|
|
| 56 |
PAPERLESS_ENABLE_NLTK=false \
|
| 57 |
PAPERLESS_OCR_CLEAN="none"
|
| 58 |
|
|
|
|
| 59 |
RUN printf "[supervisord]\nnodaemon=true\n\n\
|
| 60 |
[program:postgresql]\ncommand=/usr/lib/postgresql/*/bin/postgres -D /var/lib/postgresql/*/main\nuser=postgres\n\n\
|
| 61 |
[program:redis]\ncommand=/usr/bin/redis-server\n\n\
|
|
@@ -63,9 +73,18 @@ RUN printf "[supervisord]\nnodaemon=true\n\n\
|
|
| 63 |
[program:paperless-consumer]\ncommand=/opt/paperless/src/manage.py document_consumer\nuser=paperless\n\n\
|
| 64 |
[program:paperless-scheduler]\ncommand=/opt/paperless/src/manage.py qcluster\nuser=paperless\n" > /etc/supervisor/conf.d/supervisord.conf
|
| 65 |
|
|
|
|
| 66 |
ENV PATH="/root/.cargo/bin:${PATH}"
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
EXPOSE 7860
|
|
|
|
| 71 |
CMD ["/startup.sh"]
|
|
|
|
| 1 |
FROM ubuntu:22.04
|
| 2 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 3 |
|
| 4 |
+
# Install required packages including git, node, pnpm support
|
| 5 |
RUN apt-get update && \
|
| 6 |
apt-get install -y --no-install-recommends \
|
| 7 |
+
git nodejs npm python3 python3-pip python3-dev \
|
| 8 |
imagemagick fonts-liberation gnupg \
|
| 9 |
libpq-dev default-libmysqlclient-dev pkg-config \
|
| 10 |
libmagic-dev libzbar0 poppler-utils \
|
|
|
|
| 12 |
pngquant zlib1g tesseract-ocr tesseract-ocr-eng \
|
| 13 |
build-essential python3-setuptools python3-wheel \
|
| 14 |
redis-server postgresql postgresql-client \
|
| 15 |
+
supervisor curl nano && \
|
| 16 |
rm -rf /var/lib/apt/lists/*
|
| 17 |
|
| 18 |
+
# Install pnpm globally to enforce frontend install
|
| 19 |
+
RUN npm install -g pnpm
|
| 20 |
+
|
| 21 |
+
# Install uv package installer
|
| 22 |
RUN curl -sSf https://astral.sh/uv/install.sh | bash
|
| 23 |
|
| 24 |
+
# Create system user and set safe git directory
|
| 25 |
RUN adduser --system --home /opt/paperless --group paperless
|
| 26 |
WORKDIR /opt/paperless
|
| 27 |
RUN git config --global --add safe.directory /opt/paperless
|
| 28 |
|
| 29 |
+
# Clone Paperless-ngx and checkout version 2.17.1
|
| 30 |
RUN git clone https://github.com/paperless-ngx/paperless-ngx.git . && \
|
| 31 |
git checkout v2.17.1
|
| 32 |
|
| 33 |
+
# Build the Angular frontend using pnpm
|
| 34 |
+
# Paperless‑ngx v2.17.1 enforces pnpm via `preinstall: npx only-allow pnpm` :contentReference[oaicite:0]{index=0}
|
| 35 |
+
RUN cd src-ui && pnpm install && pnpm exec ng build -- --configuration production
|
| 36 |
|
| 37 |
+
# Install Python dependencies
|
| 38 |
RUN /root/.cargo/bin/uv pip install -r requirements.txt
|
| 39 |
|
| 40 |
+
# Initialize PostgreSQL
|
| 41 |
RUN service postgresql start && \
|
| 42 |
su - postgres -c "psql -c \"CREATE USER paperless WITH PASSWORD 'your_db_password';\"" && \
|
| 43 |
su - postgres -c "psql -c \"CREATE DATABASE paperless OWNER paperless;\"" && \
|
| 44 |
service postgresql stop
|
| 45 |
|
| 46 |
+
# Create directories for Paperless media, data, etc.
|
| 47 |
RUN mkdir -p media data consume export && \
|
| 48 |
chown -R paperless:paperless media data consume export
|
| 49 |
|
| 50 |
+
# Set environment variables for Paperless‑ngx
|
| 51 |
ENV PAPERLESS_REDIS="redis://localhost:6379/0" \
|
| 52 |
PAPERLESS_DBENGINE="postgresql" \
|
| 53 |
PAPERLESS_DBHOST="localhost" \
|
|
|
|
| 65 |
PAPERLESS_ENABLE_NLTK=false \
|
| 66 |
PAPERLESS_OCR_CLEAN="none"
|
| 67 |
|
| 68 |
+
# Create supervisord config
|
| 69 |
RUN printf "[supervisord]\nnodaemon=true\n\n\
|
| 70 |
[program:postgresql]\ncommand=/usr/lib/postgresql/*/bin/postgres -D /var/lib/postgresql/*/main\nuser=postgres\n\n\
|
| 71 |
[program:redis]\ncommand=/usr/bin/redis-server\n\n\
|
|
|
|
| 73 |
[program:paperless-consumer]\ncommand=/opt/paperless/src/manage.py document_consumer\nuser=paperless\n\n\
|
| 74 |
[program:paperless-scheduler]\ncommand=/opt/paperless/src/manage.py qcluster\nuser=paperless\n" > /etc/supervisor/conf.d/supervisord.conf
|
| 75 |
|
| 76 |
+
# Update PATH to include uv
|
| 77 |
ENV PATH="/root/.cargo/bin:${PATH}"
|
| 78 |
|
| 79 |
+
# Startup script: PostgreSQL, Redis, Django migrations, superuser, and launch supervisor
|
| 80 |
+
RUN printf "#!/bin/bash\n\
|
| 81 |
+
service postgresql start\n\
|
| 82 |
+
service redis-server start\n\
|
| 83 |
+
cd /opt/paperless\n\
|
| 84 |
+
python3 src/manage.py migrate\n\
|
| 85 |
+
python3 src/manage.py createsuperuser --noinput --username admin --email admin@example.com || true\n\
|
| 86 |
+
exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf\n" > /startup.sh && chmod +x /startup.sh
|
| 87 |
|
| 88 |
EXPOSE 7860
|
| 89 |
+
|
| 90 |
CMD ["/startup.sh"]
|