linuxserver / docker-babybuddy

GNU General Public License v3.0
38 stars 12 forks source link

Error when using postgres #5

Closed BenjaminHae closed 3 years ago

BenjaminHae commented 3 years ago

Expected Behavior

Babybuddy application connecting to postgres db when configured to do so using DB_ENGINE.

Current Behavior

Error indicating libraries necessary for postgres are not present.

Steps to Reproduce

  1. Configure the docker container with env variable DB_ENGINE='django.db.backends.postgresql

Environment

OS: Debian GNU/Linux 10 CPU architecture: x86_64 How docker service was installed: official docker repo

Command used to create docker container (run/create/compose/screenshot)

Using ansible:

    - name: setup app container
      docker_container:
        name: "{{ babybuddy.container_name }}"
        image: ghcr.io/linuxserver/babybuddy
        restart_policy: unless-stopped
        state: started
        env:
          DB_ENGINE: "django.db.backends.postgresql"
          DB_PASSWORD: "{{ babybuddy_db_password }}"
        recreate: true
        purge_networks: true
        networks:
          - name: "{{ rp_network }}"
          - name: "{{ babybuddy.network }}"
        exposed_ports:
          - '8000'
        published_ports: []
        pull: yes

Docker logs

To support the app dev(s) visit:
BabyBuddy: https://github.com/sponsors/cdubz

To support LSIO projects visit:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------

User uid:    911
User gid:    911
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 30-config: executing...
**** No secret key found, generating one ****
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 25, in <module>
    import psycopg2 as Database
  File "/usr/lib/python3.9/site-packages/psycopg2/__init__.py", line 51, in <module>
    from psycopg2._psycopg import (                     # noqa
ImportError: Error loading shared library libpq.so.5: No such file or directory (needed by /usr/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-x86_64-linux-musl.so)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/babybuddy/manage.py", line 27, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
    django.setup()
  File "/usr/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/lib/python3.9/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/usr/lib/python3.9/site-packages/django/apps/config.py", line 301, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 855, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/app/babybuddy/babybuddy/models.py", line 5, in <module>
    from django.contrib.auth.models import User
  File "/usr/lib/python3.9/site-packages/django/contrib/auth/models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/usr/lib/python3.9/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
    class AbstractBaseUser(models.Model):
  File "/usr/lib/python3.9/site-packages/django/db/models/base.py", line 122, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "/usr/lib/python3.9/site-packages/django/db/models/base.py", line 326, in add_to_class
    value.contribute_to_class(cls, name)
  File "/usr/lib/python3.9/site-packages/django/db/models/options.py", line 207, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/usr/lib/python3.9/site-packages/django/utils/connection.py", line 15, in __getattr__
    return getattr(self._connections[self._alias], item)
  File "/usr/lib/python3.9/site-packages/django/utils/connection.py", line 62, in __getitem__
    conn = self.create_connection(alias)
  File "/usr/lib/python3.9/site-packages/django/db/utils.py", line 204, in create_connection
    backend = load_backend(db['ENGINE'])
  File "/usr/lib/python3.9/site-packages/django/db/utils.py", line 111, in load_backend
    return import_module('%s.base' % backend_name)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 29, in <module>
    raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: Error loading shared library libpq.so.5: No such file or directory (needed by /usr/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-x86_64-linux-musl.so)
[...]
github-actions[bot] commented 3 years ago

Thanks for opening your first issue here! Be sure to follow the bug or feature issue templates!

thespad commented 3 years ago

Looks like we need to add libpq to the image for postgres support, we'll take a look.