]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: Make management commands aware of the container environment (#9499)
authorTrenton H <797416+stumpylog@users.noreply.github.com>
Wed, 26 Mar 2025 21:17:10 +0000 (14:17 -0700)
committerGitHub <noreply@github.com>
Wed, 26 Mar 2025 21:17:10 +0000 (14:17 -0700)
Dockerfile
docker/compose/docker-compose.mariadb-tika.yml
docker/compose/docker-compose.mariadb.yml
docker/compose/docker-compose.portainer.yml
docker/compose/docker-compose.postgres-tika.yml
docker/compose/docker-compose.postgres.yml
docker/compose/docker-compose.sqlite-tika.yml
docker/compose/docker-compose.sqlite.yml
docker/install_management_commands.sh
docker/rootfs/usr/local/bin/createsuperuser [new file with mode: 0755]
docs/setup.md

index f56422a8ee7ae796a24c6a5902ab17471a906d4d..a7ea8b70f8dc7cd29b231b9503511d2ed72bde3b 100644 (file)
@@ -239,6 +239,7 @@ COPY --from=compile-frontend --chown=1000:1000 /src/src/documents/static/fronten
 # add users, setup scripts
 # Mount the compiled frontend to expected location
 RUN set -eux \
+  && sed -i '1s|^#!/usr/bin/env python3|#!/command/with-contenv python3|' manage.py \
   && echo "Setting up user/group" \
     && addgroup --gid 1000 paperless \
     && useradd --uid 1000 --gid paperless --home-dir /usr/src/paperless paperless \
index c158797a57665b355a8f85e3455250c8f34c8d7d..845681cc8f9458aa7acd809cc6a033ca73e2f013 100644 (file)
 # - Copy this file as 'docker-compose.yml' and the files 'docker-compose.env'
 #   and '.env' into a folder.
 # - Run 'docker compose pull'.
-# - Run 'docker compose run --rm webserver createsuperuser' to create a user.
 # - Run 'docker compose up -d'.
+# - Wait until the webserver has completed startup
+# - Run 'docker compose exec webserver createsuperuser' to create a user.
+
 #
 # For more extensive installation and update instructions, refer to the
 # documentation.
index 0b7a0fd3e574710d2c77a4250754318083a55f3a..9b8d57f4a9fe173c665b67d98ece038abfdbdc41 100644 (file)
@@ -20,8 +20,9 @@
 # - Copy this file as 'docker-compose.yml' and the files 'docker-compose.env'
 #   and '.env' into a folder.
 # - Run 'docker compose pull'.
-# - Run 'docker compose run --rm webserver createsuperuser' to create a user.
 # - Run 'docker compose up -d'.
+# - Wait until the webserver has completed startup
+# - Run 'docker compose exec webserver createsuperuser' to create a user.
 #
 # For more extensive installation and update instructions, refer to the
 # documentation.
index 2132c67a69f8beeec77164d46236d88a17e282d9..455b2004ea79a8d0ee9d75a02355a62df0875b46 100644 (file)
@@ -24,7 +24,7 @@
 # - Click 'Deploy the stack' and wait for it to be deployed
 # - Open the list of containers, select paperless_webserver_1
 # - Click 'Console' and then 'Connect' to open the command line inside the container
-# - Run 'python3 manage.py createsuperuser' to create a user
+# - Run 'createsuperuser' to create a user
 # - Exit the console
 #
 # For more extensive installation and update instructions, refer to the
index 60bfada5f6590d44385d69797d109f39d94fcf9b..dd81bd5b9b1f47b6b583a70f351421f51cc0a0f6 100644 (file)
@@ -24,8 +24,9 @@
 # - Copy this file as 'docker-compose.yml' and the files 'docker-compose.env'
 #   and '.env' into a folder.
 # - Run 'docker compose pull'.
-# - Run 'docker compose run --rm webserver createsuperuser' to create a user.
 # - Run 'docker compose up -d'.
+# - Wait until the webserver has completed startup
+# - Run 'docker compose exec webserver createsuperuser' to create a user.
 #
 # For more extensive installation and update instructions, refer to the
 # documentation.
index da2953b7b47b775179826f933f52e507c78d42c1..8212f8514402bb38bab30e8e092cced32d118a8e 100644 (file)
@@ -20,8 +20,9 @@
 # - Copy this file as 'docker-compose.yml' and the files 'docker-compose.env'
 #   and '.env' into a folder.
 # - Run 'docker compose pull'.
-# - Run 'docker compose run --rm webserver createsuperuser' to create a user.
 # - Run 'docker compose up -d'.
+# - Wait until the webserver has completed startup
+# - Run 'docker compose exec webserver createsuperuser' to create a user.
 #
 # For more extensive installation and update instructions, refer to the
 # documentation.
index 54292a845d16a3bdfa7f2c85d6f0782f1ca6bdb0..d2a74b6967fdac8e4d94e9034b4d802d044801ab 100644 (file)
@@ -24,8 +24,9 @@
 # - Copy this file as 'docker-compose.yml' and the files 'docker-compose.env'
 #   and '.env' into a folder.
 # - Run 'docker compose pull'.
-# - Run 'docker compose run --rm webserver createsuperuser' to create a user.
 # - Run 'docker compose up -d'.
+# - Wait until the webserver has completed startup
+# - Run 'docker compose exec webserver createsuperuser' to create a user.
 #
 # For more extensive installation and update instructions, refer to the
 # documentation.
index 1ca5fe86b29c1b39233ccdf2e74e561a319fd24d..db63633fe883994e4ed663b8b444202d88e7f7c8 100644 (file)
@@ -17,8 +17,9 @@
 # - Copy this file as 'docker-compose.yml' and the files 'docker-compose.env'
 #   and '.env' into a folder.
 # - Run 'docker compose pull'.
-# - Run 'docker compose run --rm webserver createsuperuser' to create a user.
 # - Run 'docker compose up -d'.
+# - Wait until the webserver has completed startup
+# - Run 'docker compose exec webserver createsuperuser' to create a user.
 #
 # For more extensive installation and update instructions, refer to the
 # documentation.
index c7c65bfbb9fa123c726e138a3bafaf2f4ad62fb7..17dae68a29502fc02fb978dd3e1d2ada163ffe5a 100755 (executable)
@@ -18,9 +18,10 @@ for command in decrypt_documents \
        document_fuzzy_match \
        manage_superuser \
        convert_mariadb_uuid \
-       prune_audit_logs;
+       prune_audit_logs \
+       createsuperuser;
 do
        echo "installing $command..."
        sed "s/management_command/$command/g" management_script.sh >"$PWD/rootfs/usr/local/bin/$command"
-       chmod +x "$PWD/rootfs/usr/local/bin/$command"
+       chmod u=rwx,g=rwx,o=rx "$PWD/rootfs/usr/local/bin/$command"
 done
diff --git a/docker/rootfs/usr/local/bin/createsuperuser b/docker/rootfs/usr/local/bin/createsuperuser
new file mode 100755 (executable)
index 0000000..f931952
--- /dev/null
@@ -0,0 +1,14 @@
+#!/command/with-contenv /usr/bin/bash
+# shellcheck shell=bash
+
+set -e
+
+cd "${PAPERLESS_SRC_DIR}"
+
+if [[ $(id -u) == 0 ]]; then
+       s6-setuidgid paperless python3 manage.py createsuperuser "$@"
+elif [[ $(id -un) == "paperless" ]]; then
+       python3 manage.py createsuperuser "$@"
+else
+       echo "Unknown user."
+fi
index 7bb71a761ff1125d9749e3bc83caa74ce1b75415..d132d90332338a45ee9285906ed86ff557060d60 100644 (file)
@@ -131,24 +131,30 @@ account. The script essentially automatically performs the steps described in [D
     by default but you can change the image to pull from Docker Hub by changing the `image`
     line to `image: paperlessngx/paperless-ngx:latest`.
 
-6.  To be able to login, you will need a "superuser". To create it,
+6.  Run `docker compose up -d`. This will create and start the necessary containers.
+
+7.  Wait for the containers to complete their startup. You can monitor the logs using Docker, such as:
+
+    ```shell-session
+    docker logs --follow webserver
+    ```
+
+8.  To be able to login, you will need a "superuser". To create it,
     execute the following command:
 
     ```shell-session
-    docker compose run --rm webserver createsuperuser
+    docker compose exec webserver createsuperuser
     ```
 
     or using docker exec from within the container:
 
     ```shell-session
-    python3 manage.py createsuperuser
+    createsuperuser
     ```
 
     This will guide you through the superuser setup.
 
-7.  Run `docker compose up -d`. This will create and start the necessary containers.
-
-8.  Congratulations! Your Paperless-ngx instance should now be accessible at `http://127.0.0.1:8000`
+9.  Congratulations! Your Paperless-ngx instance should now be accessible at `http://127.0.0.1:8000`
     (or similar, depending on your configuration). Use the superuser credentials you have
     created in the previous step to login.