michaelmob / docker-funkwhale

All-in-one funkwhale docker image.
92 stars 18 forks source link

/app/api Directory Permissions #5

Open SxthGear opened 5 years ago

SxthGear commented 5 years ago

Seems that permissions set at start in the /app/api directory are not correct, causing multiple permissions errors on start:

Celery PID Traceback (most recent call last): File "/usr/bin/celery", line 11, in <module> sys.exit(main()) File "/usr/lib/python3.6/site-packages/celery/__main__.py", line 16, in main _main() File "/usr/lib/python3.6/site-packages/celery/bin/celery.py", line 322, in main cmd.execute_from_commandline(argv) File "/usr/lib/python3.6/site-packages/celery/bin/celery.py", line 484, in execute_from_commandline super(CeleryCommand, self).execute_from_commandline(argv))) File "/usr/lib/python3.6/site-packages/celery/bin/base.py", line 275, in execute_from_commandline return self.handle_argv(self.prog_name, argv[1:]) File "/usr/lib/python3.6/site-packages/celery/bin/celery.py", line 476, in handle_argv return self.execute(command, argv) File "/usr/lib/python3.6/site-packages/celery/bin/celery.py", line 408, in execute ).run_from_argv(self.prog_name, argv[1:], command=argv[0]) File "/usr/lib/python3.6/site-packages/celery/bin/base.py", line 279, in run_from_argv sys.argv if argv is None else argv, command) File "/usr/lib/python3.6/site-packages/celery/bin/base.py", line 362, in handle_argv return self(*args, **options) File "/usr/lib/python3.6/site-packages/celery/bin/base.py", line 238, in __call__ ret = self.run(*args, **kwargs) File "/usr/lib/python3.6/site-packages/celery/bin/beat.py", line 109, in run return beat().run() File "/usr/lib/python3.6/site-packages/celery/apps/beat.py", line 81, in run self.start_scheduler() File "/usr/lib/python3.6/site-packages/celery/apps/beat.py", line 92, in start_scheduler platforms.create_pidlock(self.pidfile) File "/usr/lib/python3.6/site-packages/celery/platforms.py", line 253, in create_pidlock pidlock = _create_pidlock(pidfile) File "/usr/lib/python3.6/site-packages/celery/platforms.py", line 263, in _create_pidlock pidlock.acquire() File "/usr/lib/python3.6/site-packages/celery/platforms.py", line 150, in acquire reraise(LockFailed, LockFailed(str(exc)), sys.exc_info()[2]) File "/usr/lib/python3.6/site-packages/vine/five.py", line 194, in reraise raise value.with_traceback(tb) File "/usr/lib/python3.6/site-packages/celery/platforms.py", line 148, in acquire self.write_pid() File "/usr/lib/python3.6/site-packages/celery/platforms.py", line 211, in write_pid pidfile_fd = os.open(self.path, PIDFILE_FLAGS, PIDFILE_MODE) celery.platforms.LockFailed: [Errno 13] Permission denied: '/app/api/celerybeat.pid'

And celery unable to set/determine the environment: Traceback (most recent call last): File "/usr/bin/celery", line 11, in <module> sys.exit(main()) File "/usr/lib/python3.6/site-packages/celery/__main__.py", line 16, in main _main() File "/usr/lib/python3.6/site-packages/celery/bin/celery.py", line 322, in main cmd.execute_from_commandline(argv) File "/usr/lib/python3.6/site-packages/celery/bin/celery.py", line 484, in execute_from_commandline super(CeleryCommand, self).execute_from_commandline(argv))) File "/usr/lib/python3.6/site-packages/celery/bin/base.py", line 275, in execute_from_commandline return self.handle_argv(self.prog_name, argv[1:]) File "/usr/lib/python3.6/site-packages/celery/bin/celery.py", line 476, in handle_argv return self.execute(command, argv) File "/usr/lib/python3.6/site-packages/celery/bin/celery.py", line 408, in execute ).run_from_argv(self.prog_name, argv[1:], command=argv[0]) File "/usr/lib/python3.6/site-packages/celery/bin/base.py", line 279, in run_from_argv sys.argv if argv is None else argv, command) File "/usr/lib/python3.6/site-packages/celery/bin/base.py", line 362, in handle_argv return self(*args, **options) File "/usr/lib/python3.6/site-packages/celery/bin/base.py", line 238, in __call__ ret = self.run(*args, **kwargs) File "/usr/lib/python3.6/site-packages/celery/bin/beat.py", line 109, in run return beat().run() File "/usr/lib/python3.6/site-packages/celery/apps/beat.py", line 81, in run self.start_scheduler() File "/usr/lib/python3.6/site-packages/celery/apps/beat.py", line 92, in start_scheduler platforms.create_pidlock(self.pidfile) File "/usr/lib/python3.6/site-packages/celery/platforms.py", line 253, in create_pidlock pidlock = _create_pidlock(pidfile) File "/usr/lib/python3.6/site-packages/celery/platforms.py", line 263, in _create_pidlock pidlock.acquire() File "/usr/lib/python3.6/site-packages/celery/platforms.py", line 150, in acquire reraise(LockFailed, LockFailed(str(exc)), sys.exc_info()[2]) File "/usr/lib/python3.6/site-packages/vine/five.py", line 194, in reraise raise value.with_traceback(tb) File "/usr/lib/python3.6/site-packages/celery/platforms.py", line 148, in acquire self.write_pid() File "/usr/lib/python3.6/site-packages/celery/platforms.py", line 211, in write_pid pidfile_fd = os.open(self.path, PIDFILE_FLAGS, PIDFILE_MODE) celery.platforms.LockFailed: [Errno 13] Permission denied: '/app/api/celerybeat.pid' Traceback (most recent call last): File "/usr/bin/daphne", line 11, in <module> sys.exit(CommandLineInterface.entrypoint()) File "/usr/lib/python3.6/site-packages/daphne/cli.py", line 147, in entrypoint cls().run(sys.argv[1:]) File "/usr/lib/python3.6/site-packages/daphne/cli.py", line 177, in run application = import_by_path(args.application) File "/usr/lib/python3.6/site-packages/daphne/utils.py", line 12, in import_by_path target = importlib.import_module(module_path) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "./config/asgi.py", line 5, in <module> django.setup() File "/usr/lib/python3.6/site-packages/django/__init__.py", line 19, in setup configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "/usr/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__ self._setup(name) File "/usr/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup self._wrapped = Settings(settings_module) File "/usr/lib/python3.6/site-packages/django/conf/__init__.py", line 106, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "./config/settings/production.py", line 14, in <module> from .common import * # noqa File "./config/settings/common.py", line 26, in <module> env.read_env(ROOT_DIR.file(".env")) File "/usr/lib/python3.6/site-packages/environ/environ.py", line 705, in file return open(self(name), *args, **kwargs) PermissionError: [Errno 13] Permission denied: '/app/api/.env'

Docker was set up following README instructions with no custom options.

michaelmob commented 5 years ago

Do you have the PUID or GUID environment variables set? Which OS are you running it on?

JoKneeMo commented 5 years ago

Even with the PUID and PGID set, the result is still the same as OP with "PermissionError: [Errno 13] Permission denied: '/app/api/.env'

The UI still loads, but you are unable to create the superuser because of this error.

michaelmob commented 5 years ago

Please try the next tag and let me know if it fixes the permissions. thetarkus/docker-funkwhale:next

JoKneeMo commented 5 years ago

The next build did not fix the issue for me. There also does not appear to be a .env file in /app/api

michaelmob commented 5 years ago

How are you running this image? Attach your command or compose file. What version of docker are you using and what OS?

Celery is only trying to read the .env file but it doesn't know it doesn't exist because it's missing permissions, meaning the file doesn't need to exist

SxthGear commented 5 years ago

Running docker 18.06.0-ce on Ubuntu-16.04.5. Here's the command:

docker create --name=funkwhale -e FUNKWHALE_URL="http://music.domain.tld" -v /docker/containers/funkwhale:/data -v /mnt/nfs/music:/music:ro -p 8093:80 thetarkus/funkwhale:latest

Still yields the same error despite pulling the latest release.

SxthGear commented 5 years ago

Just an update to this issue: Did a clean build and it looks like the api/environment issues are solved, however opening the URL now gives a 500 server error. Here's the log:

2019-02-09 15:27:09,011 ERROR Exception inside application: [Errno 13] Permission denied: '/app/api/funkwhale_api/templates/500.html' File "/usr/lib/python3.6/site-packages/channels/http.py", line 202, in __call__ await self.handle(body) File "/usr/lib/python3.6/site-packages/asgiref/sync.py", line 108, in __call__ return await asyncio.wait_for(future, timeout=None) File "/usr/lib/python3.6/asyncio/tasks.py", line 339, in wait_for return (yield from fut) File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/usr/lib/python3.6/site-packages/asgiref/sync.py", line 123, in thread_handler return self.func(*args, **kwargs) File "/usr/lib/python3.6/site-packages/channels/http.py", line 233, in handle response = self.get_response(request) File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 78, in get_response response = self._middleware_chain(request) File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner response = response_for_exception(request, exc) File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info()) File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 129, in handle_uncaught_exception return callback(request, **param_dict) File "/usr/lib/python3.6/site-packages/django/utils/decorators.py", line 142, in _wrapped_view response = view_func(request, *args, **kwargs) File "/usr/lib/python3.6/site-packages/django/views/defaults.py", line 72, in server_error template = loader.get_template(template_name) File "/usr/lib/python3.6/site-packages/django/template/loader.py", line 15, in get_template return engine.get_template(template_name) File "/usr/lib/python3.6/site-packages/django/template/backends/django.py", line 34, in get_template return Template(self.engine.get_template(template_name), self) File "/usr/lib/python3.6/site-packages/django/template/engine.py", line 144, in get_template template, origin = self.find_template(template_name) File "/usr/lib/python3.6/site-packages/django/template/engine.py", line 126, in find_template template = loader.get_template(name, skip=skip) File "/usr/lib/python3.6/site-packages/django/template/loaders/cached.py", line 54, in get_template template = super().get_template(template_name, skip) File "/usr/lib/python3.6/site-packages/django/template/loaders/base.py", line 24, in get_template contents = self.get_contents(origin) File "/usr/lib/python3.6/site-packages/django/template/loaders/cached.py", line 23, in get_contents return origin.loader.get_contents(origin) File "/usr/lib/python3.6/site-packages/django/template/loaders/filesystem.py", line 23, in get_contents with open(origin.name, encoding=self.engine.file_charset) as fp: [Errno 13] Permission denied: '/app/api/funkwhale_api/templates/500.html'

michaelmob commented 5 years ago

Just to clarify, you built the image or you pulled it? It sounds like there's a permissions issue with the host rather than the container.

In any case, (use a temporary /data directory that hasn't been touched yet) try running

PUID=$(id -u $USER)
PGID=$(id -G $USER | cut -d ' ' -f 1)
docker create --name=funkwhale -e FUNKWHALE_HOSTNAME="http://music.domain.tld" -e PUID=$PUID -e PGID=$PGID -v /docker/containers/funkwhale:/data -v /mnt/nfs/music:/music:ro -p 8093:80 thetarkus/funkwhale:latest
SxthGear commented 5 years ago

Sorry, pulled a new image. Unfortunately no change, still getting a "Daphne 500 error" page served along with the permission denied in the log, and that's it.

alfureu commented 5 years ago

same here, any update?

milosbabovic commented 5 years ago

Same here. Created container within QNAP Container station. The following (along with "500 Internal Server Error Exception inside application Daphne") happens on every web request:

File "/usr/lib/python3.6/site-packages/django/template/loaders/filesystem.py", line 23, in get_contents
with open(origin.name, encoding=self.engine.file_charset) as fp:
[Errno 13] Permission denied: '/app/api/funkwhale_api/templates/500.html'
2019-04-17 13:20:02,157 ERROR Exception inside application: [Errno 13] Permission denied: '/app/api/funkwhale_api/templates/500.html'
File "/usr/lib/python3.6/site-packages/channels/http.py", line 202, in call
await self.handle(body)
File "/usr/lib/python3.6/site-packages/asgiref/sync.py", line 108, in call
return await asyncio.wait_for(future, timeout=None)
File "/usr/lib/python3.6/asyncio/tasks.py", line 339, in wait_for
return (yield from fut)
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, self.kwargs)
File "/usr/lib/python3.6/site-packages/asgiref/sync.py", line 123, in thread_handler
return self.func(args, kwargs)
File "/usr/lib/python3.6/site-packages/channels/http.py", line 233, in handle
response = self.get_response(request)
File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 78, in get_response
response = self._middleware_chain(request)
File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
response = response_for_exception(request, exc)
File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 129, in handle_uncaught_exception
return callback(request,
param_dict)
File "/usr/lib/python3.6/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
response = view_func(request,
args,
kwargs)
File "/usr/lib/python3.6/site-packages/django/views/defaults.py", line 72, in server_error
template = loader.get_template(template_name)
File "/usr/lib/python3.6/site-packages/django/template/loader.py", line 15, in get_template
return engine.get_template(template_name)
File "/usr/lib/python3.6/site-packages/django/template/backends/django.py", line 34, in get_template
return Template(self.engine.get_template(template_name), self)
File "/usr/lib/python3.6/site-packages/django/template/engine.py", line 144, in get_template
template, origin = self.find_template(template_name)
File "/usr/lib/python3.6/site-packages/django/template/engine.py", line 126, in find_template
template = loader.get_template(name, skip=skip)
File "/usr/lib/python3.6/site-packages/django/template/loaders/cached.py", line 54, in get_template
template = super().get_template(template_name, skip)
File "/usr/lib/python3.6/site-packages/django/template/loaders/base.py", line 24, in get_template
contents = self.get_contents(origin)
File "/usr/lib/python3.6/site-packages/django/template/loaders/cached.py", line 23, in get_contents
return origin.loader.get_contents(origin)
File "/usr/lib/python3.6/site-packages/django/template/loaders/filesystem.py", line 23, in get_contents
with open(origin.name, encoding=self.engine.file_charset) as fp:
[Errno 13] Permission denied: '/app/api/funkwhale_api/templates/500.html'

peguerosdc commented 5 years ago

Have the same issue here! I logged in to the container to check those files (i.e. '/app/api/funkwhale_api/templates/500.html') and they don't even exist (which triggers the "permission denied"). My '/app/api/funkwhale_api/templates/' folder only contains two folders 'account' and 'registration', so apparently the image was not created correctly. Any fix for this?

TristBella commented 5 years ago

I would like to connect this docker to LDAP, but there is no .env file for configuration. Where can i create or view the file?