creativecommons / legaldb

CC Legal Database: curated repository of Case Law and Scholarship data from around the world in a Django based website.
https://LegalDB.CreativeCommons.org/
MIT License
44 stars 54 forks source link

[Bug] The .env.template as is is not enough to get the repo going locally via Docker #200

Open FatumaA opened 1 day ago

FatumaA commented 1 day ago

Description

There were many issues getting legalDB running, all related to environmental variables.

Reproduction

Clone the repo and follow the instructions in the README to run via docker. Notice the errors that show up.

First error:

/CreativeCommons/legaldb/docker-compose.yml: error while interpolating services.app.environment.[]: required variable DJANGO_SECRET_KEY is missing a value

Then:

/CreativeCommons/legaldb/docker-compose.yml: error while interpolating services.app.environment.[]: required variable DJANGO_SUPERUSER_PASSWORD is missing a value

Then: (I've shortened this, but at this point it gets stuck in a loop where it starts and restarts)

docker compose up --build
[+] Building 3.7s (14/14) FINISHED                  docker:desktop-linux
 => [app internal] load build definition from Dockerfile            0.0s
 => => transferring dockerfile: 1.66kB                              0.0s
 => [app internal] load .dockerignore                               0.0s
 => => transferring context: 95B                                    0.0s
 => [app internal] load metadata for docker.io/library/python:3.12  3.6s
 => [app 1/9] FROM docker.io/library/python:3.12@sha256:785fef11f4  0.0s
 => [app internal] load build context                               0.0s
 => => transferring context: 62B                                    0.0s
 => CACHED [app 2/9] WORKDIR /root                                  0.0s
 => CACHED [app 3/9] RUN apt-config dump | grep -E '^APT::Install-  0.0s
 => CACHED [app 4/9] RUN apt-get update     && apt-get install -y   0.0s
 => CACHED [app 5/9] RUN pip install --upgrade     pip     setupto  0.0s
 => CACHED [app 6/9] COPY Pipfile Pipfile.lock .                    0.0s
 => CACHED [app 7/9] RUN pipenv sync --dev --system                 0.0s
 => CACHED [app 8/9] WORKDIR /legaldb                               0.0s
 => CACHED [app 9/9] RUN useradd --create-home --shell /bin/bash u  0.0s
 => [app] exporting to image                                        0.0s
 => => exporting layers                                             0.0s
 => => writing image sha256:afed789dbe7b4c4b4b79b825716e3299af8e6b  0.0s
 => => naming to docker.io/library/legaldb-app                      0.0s
[+] Running 2/2
 ✔ Container legaldb-db-1   Recreated                               0.2s 
 ✔ Container legaldb-app-1  Recreated                               0.1s 
Attaching to legaldb-app-1, legaldb-db-1
legaldb-app-1  | bash: connect: Connection refused
legaldb-app-1  | bash: line 1: /dev/tcp/db/5432: Connection refused
legaldb-app-1  | bash: connect: Connection refused
legaldb-app-1  | bash: line 1: /dev/tcp/db/5432: Connection refused
legaldb-db-1   | 
legaldb-db-1   | PostgreSQL Database directory appears to contain a database; Skipping initialization
legaldb-db-1   | 
legaldb-db-1   | 2024-10-07 16:18:13.304 UTC [1] LOG:  starting PostgreSQL 16.4 on aarch64-unknown-linux-musl, compiled by gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309, 64-bit
legaldb-db-1   | 2024-10-07 16:18:13.304 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
legaldb-db-1   | 2024-10-07 16:18:13.304 UTC [1] LOG:  listening on IPv6 address "::", port 5432
legaldb-db-1   | 2024-10-07 16:18:13.311 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
legaldb-db-1   | 2024-10-07 16:18:13.371 UTC [31] LOG:  database system was shut down at 2024-10-07 16:16:26 UTC
legaldb-db-1   | 2024-10-07 16:18:13.427 UTC [1] LOG:  database system is ready to accept connections
legaldb-app-1  | ERROR (1) Unhandled exception:
legaldb-app-1  | Traceback (most recent call last):
legaldb-app-1  |   File "/legaldb/./manage.py", line 32, in <module>
legaldb-app-1  |     main()
legaldb-app-1  |   File "/legaldb/./manage.py", line 27, in main
legaldb-app-1  |     execute_from_command_line(sys.argv)

From above, these seem to be the main issue:

bash: connect: Connection refused
bash: line 1: /dev/tcp/db/5432: Connection refused

ValueError: invalid truth value ''

This is where I got stuck before I realized I needed to set these two variables explicitly

DJANGO_COMPRESS_ENABLED=
DJANGO_COMPRESS_OFFLINE=

This may be obvious for people who use Django regularly, but it wasn't to me and some of the other Outreachy participants, as seen in the Slack channel discussions.

Expectation

Instructions should run the app seamlessly. The env.temnplate should be more specific and the README too.

Environment

MacOS 15.5

Additional context

Run into this while trying to set up for Outreachy

Resolution

TimidRobot commented 1 day ago

@FatumaA please update the description of this issue with the errors encountered

FatumaA commented 1 day ago

Hi, Done 🙂