ciur / papermerge

Open Source Document Management System for Digital Archives (Scanned Documents)
https://papermerge.com
Apache License 2.0
2.55k stars 267 forks source link

Failed to start Papermerge inside Docker #471

Closed makaanneo closed 2 years ago

makaanneo commented 2 years ago

In case you experience issues with docker image provided by linuxserver.io/papermerge, please open bug report in their repository.

Description Followed the description in the documentation to get started for setup.

  1. create a local docker-compose.yaml
  2. create .env file with content from mentioned as starting point inside documentation
    
    APP_IMAGE=ghcr.io/papermerge/papermerge
    APP_TAG=latest
    PAPERMERGE_JS_IMAGE=ghcr.io/papermerge/papermerge.js
    PAPERMERGE_JS_TAG=latest

DB_USER=postgres DB_NAME=postgres DB_PASSWORD=postgres DB_HOST=db DB_PORT=5432

USE_HOSTNAME=papermerge.local

REDIS_HOST=redis REDIS_PORT=6379

ES_HOSTS=es ES_PORT=9200

SECRET_KEY=12345abcdxyz

SUPERUSER_USERNAME=admin SUPERUSER_EMAIL=admin@example.com SUPERUSER_PASSWORD=admin

4. Start on pwsh 
 ```powershell
docker compose -f docker-compose.yaml --env-file .env up
  1. login works as expected with default credentials (admin/admin)
  2. try to add folder

Expected No exception and application can be used

Actual error in js - Uncaught (in promise) TypeError: Q.randomUUID is not a function grafik

Info:

amcusack commented 2 years ago

Seeing exactly the same error here..

just installed using the documented portainer method https://docs.papermerge.io/Installation/portainer.html

Uncaught (in promise) TypeError: Q.randomUUID is not a function
    at ie.te [as _generate] (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4727:47)
    at ie.createIdentifierForNewRecord (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4734:340)
    at be._build (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4804:12)
    at be.build (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4801:84)
    at vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4963:18
    at U._run (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3229:94)
    at U._join (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3228:234)
    at U.join (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3194:13)
    at vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4960:119
    at U._run (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3229:94)
te @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4727
createIdentifierForNewRecord @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4734
_build @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4804
build @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4801
(anonymous) @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4963
_run @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3229
_join @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3228
join @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3194
(anonymous) @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4960
_run @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3229
_join @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3228
join @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3194
createRecord @ vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4960
onSubmit @ papermerge-096a5e9669979e53a4107446fd672eab.js:236

Debian GNU/Linux 11 (bullseye) Docker version 20.10.5+dfsg1, build 55c4c88 Chrome/Edge/Firefox/Brave (latest versions) all return same error

ciur commented 2 years ago

Looks like a general issue i.e. does not depend on operating system

4nx commented 2 years ago

Same problem here with Alpine Linux 3.15, Docker Version 20.10.16 and any browser.

Backend container logs shows this:

93 static files copied to '/app/static'.
Operations to perform:
  Apply all migrations: auth, authtoken, contenttypes, core, dynamic_preferences, dynamic_preferences_users, knox, sessions, sites
Running migrations:
Traceback (most recent call last):
  File "/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(core_user, 2200) already exists.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/manage.py", line 22, in <module>
    main()
  File "/app/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/venv/lib/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/venv/lib/python3.9/site-packages/django/core/management/base.py", line 460, in execute
    output = self.handle(*args, **options)
  File "/venv/lib/python3.9/site-packages/django/core/management/base.py", line 98, in wrapped
    res = handle_func(*args, **kwargs)
  File "/venv/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 290, in handle
    post_migrate_state = executor.migrate(
  File "/venv/lib/python3.9/site-packages/django/db/migrations/executor.py", line 131, in migrate
    state = self._migrate_all_forwards(
  File "/venv/lib/python3.9/site-packages/django/db/migrations/executor.py", line 163, in _migrate_all_forwards
    state = self.apply_migration(
  File "/venv/lib/python3.9/site-packages/django/db/migrations/executor.py", line 248, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/venv/lib/python3.9/site-packages/django/db/migrations/migration.py", line 131, in apply
    operation.database_forwards(
  File "/venv/lib/python3.9/site-packages/django/db/migrations/operations/models.py", line 93, in database_forwards
    schema_editor.create_model(model)
  File "/venv/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 432, in create_model
    self.execute(sql, params or None)
  File "/venv/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 192, in execute
    cursor.execute(sql, params)
  File "/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/venv/lib/python3.9/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(core_user, 2200) already exists.

  Applying core.0001_initial...Creating superuser username=admin
WARNING 2022-08-15 19:34:49,374 base GET http://es:9200/ [status:N/A request:0.044s]
Traceback (most recent call last):
  File "/venv/lib/python3.9/site-packages/django/db/models/query.py", line 657, in get_or_create
    return self.get(**kwargs), False
  File "/venv/lib/python3.9/site-packages/django/db/models/query.py", line 496, in get
    raise self.model.DoesNotExist(
papermerge.core.models.folder.Folder.DoesNotExist: Folder matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/venv/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/venv/lib/python3.9/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/venv/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/venv/lib/python3.9/site-packages/elasticsearch/connection/http_urllib3.py", line 255, in perform_request
    response = self.pool.urlopen(
  File "/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/venv/lib/python3.9/site-packages/urllib3/util/retry.py", line 525, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/venv/lib/python3.9/site-packages/urllib3/packages/six.py", line 770, in reraise
    raise value
  File "/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/venv/lib/python3.9/site-packages/urllib3/connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.9/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1331, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1280, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1040, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.9/http/client.py", line 980, in send
    self.connect()
  File "/venv/lib/python3.9/site-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
  File "/venv/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f52bfa654c0>: Failed to establish a new connection: [Errno 111] Connection refused
WARNING 2022-08-15 19:34:49,393 signals Elastic search connection error
WARNING 2022-08-15 19:34:49,521 base GET http://es:9200/ [status:N/A request:0.003s]
Traceback (most recent call last):
  File "/venv/lib/python3.9/site-packages/django/db/models/query.py", line 657, in get_or_create
    return self.get(**kwargs), False
  File "/venv/lib/python3.9/site-packages/django/db/models/query.py", line 496, in get
    raise self.model.DoesNotExist(
papermerge.core.models.folder.Folder.DoesNotExist: Folder matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/venv/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/venv/lib/python3.9/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/venv/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/venv/lib/python3.9/site-packages/elasticsearch/connection/http_urllib3.py", line 255, in perform_request
    response = self.pool.urlopen(
  File "/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/venv/lib/python3.9/site-packages/urllib3/util/retry.py", line 525, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/venv/lib/python3.9/site-packages/urllib3/packages/six.py", line 770, in reraise
    raise value
  File "/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/venv/lib/python3.9/site-packages/urllib3/connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.9/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1331, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1280, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1040, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.9/http/client.py", line 980, in send
    self.connect()
  File "/venv/lib/python3.9/site-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
  File "/venv/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f52bfa65e20>: Failed to establish a new connection: [Errno 111] Connection refused
WARNING 2022-08-15 19:34:49,525 signals Elastic search connection error
Superuser created successfully.

Beside database errors there seem to be connection problems to elastic search. Although from within the container the http based connection seems to be functional:

# python -c "import urllib.request as r; print(r.urlopen('http://es:9200').read())"

b'{\n  "name" : "fe7e278e159c",\n  "cluster_name" : "docker-cluster",\n  "cluster_uuid" : "Kv8mj-4AR72HDyEpZfpUig",\n  "version" : {\n    "number" : "7.16.2",\n    "build_flavor" : "default",\n    "build_type" : "docker",\n    "build_hash" : "2b937c44140b6559905130a8650c64dbd0879cfb",\n    "build_date" : "2021-12-18T19:42:46.604893745Z",\n    "build_snapshot" : false,\n    "lucene_version" : "8.10.1",\n    "minimum_wire_compatibility_version" : "6.8.0",\n    "minimum_index_compatibility_version" : "6.0.0-beta1"\n  },\n  "tagline" : "You Know, for Search"\n}\n'
ciur commented 2 years ago

I was able to reproduce the problem. I got exactly same error on frontend side:

vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4727 Uncaught (in promise) TypeError: Q.randomUUID is not a function
    at ie.te [as _generate] (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4727:47)
    at ie.createIdentifierForNewRecord (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4734:340)
    at be._build (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4804:12)
    at be.build (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4801:84)
    at vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4963:18
    at U._run (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3229:94)
    at U._join (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3228:234)
    at U.join (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3194:13)
    at vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:4960:119
    at U._run (vendor-fe16d39c99c858dfbe7954f7b52e67f7.js:3229:94)

I was able to create folders using REST API though.

Investigating...

ciur commented 2 years ago

Found it: https://github.com/emberjs/data/issues/8106 https://github.com/emberjs/data/issues/8097 https://github.com/WICG/uuid/issues/23

Basically the problem is that ember data uses crypto.randomUUID to generate its IDs, however, the randomUUID method (provided by the browser) is available only in so called "secure contexts", which is a fancy way to say - that it is available only when application is served over HTTPS, which in this case is not.

The solution is to provide a custom method for generating ember data IDs. Fix will follow...

ciur commented 2 years ago

The fix is now part of 2.1.0a39 docker image.

@makaanneo, @4nx could you please check papermerge.js:2.1.0a39 docker image and confirm that indeed it fixes the issue ?

Latest tag for backend docker image is 2.1.0a38 Latest tag for frontend docker image is 2.1.0a39

4nx commented 2 years ago

@ciur I can confirm that this fixed the problem.