projectcaluma / alexandria

Document management service
GNU General Public License v3.0
4 stars 10 forks source link

Quick start not working #421

Open zvyn opened 7 months ago

zvyn commented 7 months ago

What I did:

  1. clone the repo and stop my local postgres instance
  2. added UID=<my user ID> to the .env file
  3. docker compose up -d
  4. make load_example_data

What happened:

After step 3 I get the following docker ps output:

$ docker ps                                                                                                                                                                                                                                                                             13:07:45
CONTAINER ID   IMAGE                                      COMMAND                  CREATED          STATUS                          PORTS                                                                                                                         NAMES
7dcbff5675bb   minio/mc:RELEASE.2023-11-06T04-19-23Z      "/bin/sh -c ' mc con…"   31 minutes ago   Restarting (1) 55 seconds ago                                                                                                                                 alexandria-mc-1
03a121b20446   minio/minio:RELEASE.2023-11-06T22-26-08Z   "/usr/bin/docker-ent…"   31 minutes ago   Up 31 minutes                   0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp, 0.0.0.0:9090->9090/tcp, :::9090->9090/tcp   alexandria-minio-1
df457f73006c   postgres:alpine                            "docker-entrypoint.s…"   31 minutes ago   Up 31 minutes                   0.0.0.0:5432->5432/tcp, :::5432->5432/tcp                                                                                     alexandria-db-1

As you can see, no service at port 8000.

Step 4 gives a stack trace ending in ModuleNotFoundError: No module named 'django_extensions'

open-dynaMIX commented 7 months ago

Did you build the container manually? The dev dependencies only get installed, if you build with the docker-compose.override.yml as there INSTALL_DEV_DEPENDENCIES is set to true.

zvyn commented 7 months ago

I ran docker compose up -d from the cloned repo, I guess that means I used the override.

So my second attempt, this time downloading the docker-compose.yml linked from the README.md into a separate folder leads to many more errors, all related to missing configuration:

$ docker compose logs db
tmp-db-1  | Error: Database is uninitialized and superuser password is not specified.
tmp-db-1  |        You must specify POSTGRES_PASSWORD to a non-empty value for the
tmp-db-1  |        superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
tmp-db-1  | 
tmp-db-1  |        You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
tmp-db-1  |        connections without a password. This is *not* recommended.
tmp-db-1  | 
tmp-db-1  |        See PostgreSQL documentation about "trust":
tmp-db-1  |        https://www.postgresql.org/docs/current/auth-trust.html
$ docker compose logs mc
tmp-mc-1  | mc: <ERROR> Invalid secret key `secret`. Invalid arguments provided, please refer `mc <command> -h` for relevant documentation.
tmp-mc-1  | Bucket created successfully `dc-minio/alexandria-media`.
$ docker compose logs minio
tmp-minio-1  | ERROR Unable to validate credentials inherited from the shell environment: Invalid credentials
tmp-minio-1  |       > Please provide correct credentials
tmp-minio-1  |       HINT:
tmp-minio-1  |         Access key length should be at least 3, and secret key length at least 8 characters
$ docker compose logs alexandria
tmp-alexandria-1  | wait-for-it: waiting 15 seconds for db:5432
tmp-alexandria-1  | wait-for-it: timeout occurred after waiting 15 seconds for db:5432
tmp-alexandria-1  | Traceback (most recent call last):
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/environ/environ.py", line 388, in get_value
tmp-alexandria-1  |     value = self.ENVIRON[var_name]
tmp-alexandria-1  |   File "/usr/local/lib/python3.8/os.py", line 675, in __getitem__
tmp-alexandria-1  |     raise KeyError(key) from None
tmp-alexandria-1  | KeyError: 'SECRET_KEY'
tmp-alexandria-1  | 
tmp-alexandria-1  | The above exception was the direct cause of the following exception:
tmp-alexandria-1  | 
tmp-alexandria-1  | Traceback (most recent call last):
tmp-alexandria-1  |   File "./manage.py", line 12, in <module>
tmp-alexandria-1  |     execute_from_command_line(sys.argv)
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
tmp-alexandria-1  |     utility.execute()
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
tmp-alexandria-1  |     self.fetch_command(subcommand).run_from_argv(self.argv)
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
tmp-alexandria-1  |     self.execute(*args, **cmd_options)
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
tmp-alexandria-1  |     output = self.handle(*args, **options)
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/django/core/management/base.py", line 86, in wrapped
tmp-alexandria-1  |     saved_locale = translation.get_language()
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/django/utils/translation/__init__.py", line 254, in get_language
tmp-alexandria-1  |     return _trans.get_language()
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/django/utils/translation/__init__.py", line 57, in __getattr__
tmp-alexandria-1  |     if settings.USE_I18N:
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
tmp-alexandria-1  |     self._setup(name)
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
tmp-alexandria-1  |     self._wrapped = Settings(settings_module)
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
tmp-alexandria-1  |     mod = importlib.import_module(self.SETTINGS_MODULE)
tmp-alexandria-1  |   File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
tmp-alexandria-1  |     return _bootstrap._gcd_import(name[level:], package, level)
tmp-alexandria-1  |   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
tmp-alexandria-1  |   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
tmp-alexandria-1  |   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
tmp-alexandria-1  |   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
tmp-alexandria-1  |   File "<frozen importlib._bootstrap_external>", line 843, in exec_module
tmp-alexandria-1  |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
tmp-alexandria-1  |   File "/app/alexandria/settings/django.py", line 8, in <module>
tmp-alexandria-1  |     SECRET_KEY = env.str("SECRET_KEY", default=default("uuuuuuuuuu"))
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/environ/environ.py", line 213, in str
tmp-alexandria-1  |     value = self.get_value(var, cast=str, default=default)
tmp-alexandria-1  |   File "/home/alexandria/.cache/pypoetry/virtualenvs/caluma-alexandria-9TtSrW0h-py3.8/lib/python3.8/site-packages/environ/environ.py", line 392, in get_value
tmp-alexandria-1  |     raise ImproperlyConfigured(error_msg) from exc
tmp-alexandria-1  | django.core.exceptions.ImproperlyConfigured: Set the SECRET_KEY environment variable
open-dynaMIX commented 7 months ago

And when calling docker compose up for the first time, the image is actually built? Or does it just use the one from ghcr? Try building it manually first:

docker compose build --pull alexandria
docker compose up -d

This only affects the dev setup with the override file. If I'm correct, then the README is missing this information.

open-dynaMIX commented 7 months ago

To be a bit more clear: When running it with the override compose file, the config set there depends on the dev dependencies. They are only installed if the image was also built with the override file.

zvyn commented 7 months ago
docker compose build --pull alexandria
docker compose up -d

Yes this works from within the repo, thanks!

So I guess instead of suggesting to download the docker-compose.yml this would work as quick-start instructions:

After installing and configuring those, clone this repo and run the following commands:

    echo UID=$UID > .env
    docker compose build --pull alexandria
    docker compose up -d
open-dynaMIX commented 7 months ago

We should differentiate between getting an Alexandria instance running and getting a dev instance running.

In README.md

For a production instance, it's not necessary to clone the repo. You just need a correct compose file.

For good reasons, the main compose file doesn't set all the env vars necessary to bring up the project. As you saw, when it complained about the missing SECRET_KEY environment variable.

We should rethink our approach here. Some configuration is needed, before you can spin up an instance, as we don't want to hardcode secrets in the main compose file.

Typically, when using Alexandria, I would create additional compose files. docker-compose.production.yml, docker-compose.staging.yml, etc.

We could add a docker-compose.demo.yml file. Then change the installation instructions to:

docker compose -f docker-compose.demo.yml up -d

And also make clear that this will spin up a demo instance that is not safe for production.

What do you think @winged?

In CONTRIBUTING.md

How to get a dev setup running is described in CONTRIBUTING.md. There the build step should be included:

# needed for permission handling
# only needs to be run once
echo UID=$UID > .env
# build image with dev dependencies
docker compose build --pull alexandria
# open shell
docker compose run --rm alexandria bash

Would be nice, if you could prepare a PR with this change.