wger-project / docker

Production...ish docker-compose image for wger
GNU Affero General Public License v3.0
125 stars 43 forks source link

Error: for celery_worker. `wger_server` is unhealthy. DB authentication issue? #87

Closed gagestinson closed 3 months ago

gagestinson commented 3 months ago

I have been struggling with this for a while now. I tried making my own volumes so they could be mounted to a different location on my host machine but then I got this error. I then tried running the docker-compose.yml file exactly as the repo has it by default along with all of the stuff in the config directory. (Everything in the compose file is the default except the host post for nginx since I already have port 80 in use)

I am getting the following output in the terminal after running docker-compose up -d:

Creating network "wger_network" with the default driver
Creating wger_cache ... done
Creating wger_db    ... done
Creating wger_server ... done
Creating wger_nginx  ... done

ERROR: for celery_worker  Container "8f69fc159297" is unhealthy.
ERROR: Encountered errors while bringing up the project.

Running docker ps | grep 8f69fc159297 I get the output:

8f69fc159297   wger/server:latest          "/home/wger/entrypoi…"   5 minutes ago   Up 5 minutes (unhealthy)     8000/tcp

               wger_server

Using Portainer I look into the logs of wger_server and this is what is shown:

.....
  File "/usr/local/lib/python3.10/dist-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/django/db/backends/base/base.py", line 270, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/usr/local/lib/python3.10/dist-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/django/db/backends/postgresql/base.py", line 275, in get_new_connection
    connection = self.Database.connect(**conn_params)
  File "/usr/local/lib/python3.10/dist-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: connection to server at "db" (172.31.0.2), port 5432 failed: FATAL:  password authentication failed for user "wger"
Using gunicorn...
[2024-06-12 19:29:39 +0000] [43] [INFO] Starting gunicorn 22.0.0
[2024-06-12 19:29:39 +0000] [43] [INFO] Listening at: http://0.0.0.0:8000 (43)
[2024-06-12 19:29:39 +0000] [43] [INFO] Using worker: sync
[2024-06-12 19:29:39 +0000] [44] [INFO] Booting worker with pid: 44
INFO 2024-06-12 21:29:40,038 apps AXES: BEGIN version 6.4.0, blocking by ip_address
ERROR 2024-06-12 21:29:41,714 log Internal Server Error: /
ERROR 2024-06-12 21:29:51,853 log Internal Server Error: /
ERROR 2024-06-12 21:30:02,012 log Internal Server Error: /
ERROR 2024-06-12 21:30:12,187 log Internal Server Error: /
ERROR 2024-06-12 21:30:22,355 log Internal Server Error: /
.....

So it looks like this is maybe some kind of authentication issue? I am not familiar with databases in the slightest so I am not sure if this is the issue or if this is just another thing on top of my problem. I am just confused since this passwords and usernames are the default that the repo uses but I am getting this error. Any suggestions?

rolandgeider commented 3 months ago

that does indeed look like an auth error, which is weird (specially since the way celery_worker connects is the exact same as the web image). Just to be sure, can you nuke all the volumes, containers etc and try again? Obviously the nginx port isn't a problem

gagestinson commented 3 months ago

Wow. Cannot believe it was that simple. Thank you for the help. Like I said I know basically nothing about databases and am not too familiar with docker from CLI. I was trying to use Portainer at first but that did not work at all so I just went with the default way.

The web interface seems to be working but when running the docker-compose file it still states that the container is unhealthy and there was an Error for celery_worker but I look at the wger_server logs and I do not see any problem

  Applying exercises.0030_increase_author_field_length... OK
  Applying gallery.0001_initial... OK
  Applying mailer.0001_initial... OK
  Applying mailer.0002_auto_20190618_1617... OK
  Applying mailer.0003_auto_20201201_0653... OK
  Applying manager.0005_auto_20160303_2008... OK
  Applying manager.0006_auto_20160303_2138... OK
  Applying manager.0007_auto_20160311_2258... OK
  Applying manager.0008_auto_20190618_1617... OK
  Applying manager.0009_auto_20201202_1559... OK
  Applying manager.0010_auto_20210102_1446... OK
  Applying manager.0011_remove_set_exercises... OK
  Applying manager.0012_auto_20210430_1449... OK
  Applying manager.0013_set_comment... OK
  Applying manager.0014_auto_20210717_1858... OK
  Applying manager.0015_auto_20211028_1113... OK
  Applying manager.0016_move_to_exercise_base... OK
  Applying manager.0017_alter_workoutlog_exercise_base... OK
  Applying measurements.0001_initial... OK
  Applying measurements.0002_auto_20210722_1042... OK
  Applying nutrition.0001_initial... OK
  Applying nutrition.0002_auto_20170101_1538... OK
  Applying nutrition.0003_auto_20170118_2308... OK
  Applying nutrition.0004_auto_20200819_2310... OK
  Applying nutrition.0005_logitem... OK
  Applying nutrition.0006_auto_20201201_0653... OK
  Applying nutrition.0007_auto_20201214_0013... OK
  Applying nutrition.0008_auto_20210102_1446... OK
  Applying nutrition.0009_meal_name... OK
  Applying nutrition.0010_logitem_meal... OK
  Applying nutrition.0011_alter_logitem_datetime... OK
  Applying nutrition.0012_alter_ingredient_license_author... OK
  Applying nutrition.0013_ingredient_image... OK
  Applying nutrition.0014_license_information... OK
  Applying nutrition.0015_alter_ingredient_creation_date_and_more... OK
  Applying nutrition.0016_alter_logitem_options_and_more... OK
  Applying nutrition.0017_remove_nutritionplan_language_alter_logitem_meal... OK
  Applying nutrition.0018_nutritionplan_goal_carbs_nutritionplan_goal_energy_and_more... OK
  Applying nutrition.0019_alter_image_license_author_and_more... OK
  Applying nutrition.0020_full_text_search... OK
  Applying nutrition.0021_add_fibers_field... OK
  Applying nutrition.0022_add_remote_id_increase_author_field_length... OK
  Applying nutrition.0023_fiber_spelling... OK
  Applying nutrition.0024_remove_ingredient_status... OK
  Applying sessions.0001_initial... OK
  Applying sites.0001_initial... OK
  Applying sites.0002_alter_domain_unique... OK
  Applying weight.0001_initial... OK
  Applying weight.0002_auto_20150604_2139... OK
  Applying weight.0003_auto_20160416_1030... OK
Installed 1 object(s) from 1 fixture(s)
Installed 24 object(s) from 1 fixture(s)
Installed 6 object(s) from 1 fixture(s)
Installed 3 object(s) from 1 fixture(s)
Installed 5 object(s) from 1 fixture(s)
Installed 7 object(s) from 1 fixture(s)
Installed 7 object(s) from 1 fixture(s)
Installed 6 object(s) from 1 fixture(s)
Installed 1 object(s) from 1 fixture(s)
Installed 10 object(s) from 1 fixture(s)
Installed 16 object(s) from 1 fixture(s)
Installed 8 object(s) from 1 fixture(s)
Installed 552 object(s) from 1 fixture(s)
Installed 1431 object(s) from 1 fixture(s)
Installed 1 object(s) from 1 fixture(s)
Installed 1 object(s) from 1 fixture(s)
Installed 1 object(s) from 1 fixture(s)
*** Password for user admin was reset to 'adminadmin'
Installed 3 object(s) from 1 fixture(s)
yarn install v1.22.22
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning " > bootstrap@5.3.3" has unmet peer dependency "@popperjs/core@^2.11.8".
[5/5] Building fresh packages...
Done in 17.62s.
yarn run v1.22.22
$ sass wger/core/static/scss/main.scss:wger/core/static/yarn/bootstrap-compiled.css
Done in 3.92s.
Running in production mode, running collectstatic now
INFO 2024-06-12 22:30:39,949 apps AXES: BEGIN version 6.4.0, blocking by ip_address
11729 static files copied to '/home/wger/static'.
Performing database migrations
INFO 2024-06-12 22:30:45,745 apps AXES: BEGIN version 6.4.0, blocking by ip_address
Operations to perform:
  Apply all migrations: actstream, auth, authtoken, axes, config, contenttypes, core, easy_thumbnails, exercises, gallery, gym, mailer, manager, measurements, nutrition, sessions, sites, weight
Running migrations:
  No migrations to apply.
  Your models in app(s): 'exercises', 'nutrition' have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
INFO 2024-06-12 22:30:48,446 apps AXES: BEGIN version 6.4.0, blocking by ip_address
Set site URL to localhost
Using gunicorn...
[2024-06-12 20:30:49 +0000] [130] [INFO] Starting gunicorn 22.0.0
[2024-06-12 20:30:49 +0000] [130] [INFO] Listening at: http://0.0.0.0:8000 (130)
[2024-06-12 20:30:49 +0000] [130] [INFO] Using worker: sync
[2024-06-12 20:30:49 +0000] [131] [INFO] Booting worker with pid: 131
INFO 2024-06-12 22:30:50,377 apps AXES: BEGIN version 6.4.0, blocking by ip_address
rolandgeider commented 3 months ago

the web service is supposed to be unhealthy? I mean if it works, it works. But I can take a look

gagestinson commented 3 months ago

It is supposed to be unhealthy? Are you able to elaborate?

It was a little strange, I was getting that issue with the celery_worker again in the terminal but after just running docker-compose down and then docker-compose up -d again a couple times it all started working okay. I am starting to have another DB authentication issue tho, but I will search the issues before posting a new one if necessary.

rolandgeider commented 3 months ago

no, no, it shouldn't be unhealthy, but there might be a problem with the health check. Also, I know from what others have tried that if instead of the volumes you map folders, you will need to tweak file and folder permissions so that everything works fine (but those shouldn't cause authentication issues, or if they do, then also in the web service, not only celery)

gagestinson commented 3 months ago

yea I am presently having that as one of my issues. Is there a previous post about this specifically for me to read?

Looking at the wger_server logs again, the lines PermissionError: [Errno 13] Permission denied: '/home/wger/static/CACHE' as well as PermissionError: [Errno 13] Permission denied: '/home/wger/static/fonts' are present. This is a directory inside the actual container and not on my host system. I tried to use the CLI to change the permissions of that directory inside the container but I do not know the root password of the container. I tried 'wger', 'root', 'admin', 'adminadmin' and those did not work.

I also tried doing the solution listed here by setting DJANGO_DEBUG=True, but that did not solve the issue.

deboy69 commented 1 month ago

Getting the same error. Any update on this?