wger-project / docker

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

Permissions error again #99

Open deboy69 opened 2 months ago

deboy69 commented 2 months ago

Can we get a deep dive into the permissions for these docker containers? I spend so much time to figure out permissions errors with this repo that I am almost getting ready to abandon it. I shouldnt have to chmod 777 for read access for these containers.

ERROR 2024-09-17 08:26:37,326 log Internal Server Error: /en/software/features Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, callback_kwargs) File "/home/wger/src/wger/software/views.py", line 67, in features return render(request, 'features.html', context) File "/usr/local/lib/python3.10/dist-packages/django/shortcuts.py", line 24, in render content = loader.render_to_string(template_name, context, request, using=using) File "/usr/local/lib/python3.10/dist-packages/django/template/loader.py", line 62, in render_to_string return template.render(context, request) File "/usr/local/lib/python3.10/dist-packages/django/template/backends/django.py", line 61, in render return self.template.render(context) File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 175, in render return self._render(context) File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 167, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 1005, in render return SafeString("".join([node.render_annotated(context) for node in self])) File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 1005, in return SafeString("".join([node.render_annotated(context) for node in self])) File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 966, in render_annotated return self.render(context) File "/usr/local/lib/python3.10/dist-packages/django/template/loader_tags.py", line 157, in render return compiled_parent._render(context) File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 167, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 1005, in render return SafeString("".join([node.render_annotated(context) for node in self])) File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 1005, in return SafeString("".join([node.render_annotated(context) for node in self])) File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 966, in render_annotated return self.render(context) File "/usr/local/lib/python3.10/dist-packages/compressor/templatetags/compress.py", line 160, in render return self.render_compressed( File "/usr/local/lib/python3.10/dist-packages/compressor/templatetags/compress.py", line 131, in render_compressed rendered_output = compressor.output(mode, forced=forced, basename=file_basename) File "/usr/local/lib/python3.10/dist-packages/compressor/css.py", line 55, in output ret.append(subnode.output(*args, *kwargs)) File "/usr/local/lib/python3.10/dist-packages/compressor/css.py", line 57, in output return super().output(args, kwargs) File "/usr/local/lib/python3.10/dist-packages/compressor/base.py", line 374, in output return self.handle_output(mode, filtered_output, forced, basename) File "/usr/local/lib/python3.10/dist-packages/compressor/base.py", line 382, in handle_output return output_func(mode, content, forced, basename) File "/usr/local/lib/python3.10/dist-packages/compressor/base.py", line 393, in output_file self.storage.save(new_filepath, ContentFile(content.encode(self.charset))) File "/usr/local/lib/python3.10/dist-packages/compressor/storage.py", line 52, in save temp_filename = super().save(filename, content) File "/usr/local/lib/python3.10/dist-packages/django/core/files/storage/base.py", line 38, in save name = self._save(name, content) File "/usr/local/lib/python3.10/dist-packages/django/core/files/storage/filesystem.py", line 87, in _save os.makedirs(directory, exist_ok=True) File "/usr/lib/python3.10/os.py", line 215, in makedirs makedirs(head, exist_ok=exist_ok) File "/usr/lib/python3.10/os.py", line 225, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/home/wger/static/CACHE'

wger@023e2a8bbd94:~$ ls -l total 28 drwxr-xr-x 2 wger wger 4096 Sep 16 15:25 beat drwxr-xr-x 2 wger wger 4096 Sep 16 15:25 db -rwxr-xr-x 1 root root 2304 Sep 16 15:20 entrypoint.sh drwxr-sr-x 2 root root 4096 Sep 17 14:24 media drwxr-xr-x 1 wger wger 4096 Sep 16 15:23 src drwxr-sr-x 2 root root 4096 Sep 17 14:24 static

deboy69 commented 3 weeks ago

@rolandgeider Any update on this issue or a proposed fix?

rolandgeider commented 3 weeks ago

hi! When you start the container the static files are copied over to the static files folder, these have the same owner as the rest of the files in the application and probably don't make problems. Then, when you start up the application, the static files are compressed into one, and this happes by the server process, so this might be the reason. I added a flag so that this compression doesn't happen, can you try to set COMPRESS_ENABLED=False and see if it helps?

deboy69 commented 3 weeks ago

It did not. Nuked the file system and started over. No change. Still cant find static images. One of several errors that are the same

Not Found: /static/images/icons/flags/hr.svg WARNING 2024-10-29 10:11:38,122 log Not Found: /static/images/icons/flags/hr.svg

deboy69 commented 3 weeks ago

Running in production mode, running collectstatic now INFO 2024-10-29 10:23:59,213 apps AXES: BEGIN version 7.0.0, blocking by ip_address Traceback (most recent call last): File "/home/wger/src/manage.py", line 24, in execute_from_command_line(sys.argv) File "/home/wger/.local/lib/python3.12/site-packages/django/core/management/init.py", line 442, in execute_from_command_line utility.execute() File "/home/wger/.local/lib/python3.12/site-packages/django/core/management/init.py", line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/wger/.local/lib/python3.12/site-packages/django/core/management/base.py", line 412, in run_from_argv self.execute(*args, *cmd_options) File "/home/wger/.local/lib/python3.12/site-packages/django/core/management/base.py", line 458, in execute output = self.handle(args, **options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

rolandgeider commented 3 weeks ago

Running in production mode, running collectstatic now

just wanted to suggest running collectstatic. Aren't there any other errors after that? Something useful like "could not write to folder" or such

Otherwise is there a reason you can't use volumes? Everything works there

deboy69 commented 3 weeks ago

just wanted to suggest running collectstatic. Aren't there any other errors after that? Something useful like "could not write to folder" or such

I have set to run the downloads of exercises etc set to run at startup with thats what you mean. No other errors. static and media are both empty

Otherwise is there a reason you can't use volumes? Everything works there

I mount the volume directly into the container. its easier for me to maintain because my config it on an external HD and no my RPI drive.

deboy69 commented 3 weeks ago

drwxr-sr-x 2 root root 4096 Oct 29 10:42 media drwxr-sr-x 2 999 root 4096 Oct 29 10:42 redis-data drwxr-sr-x 2 root root 4096 Oct 29 10:42 static

I dont even have a 999 on my system