Compose configuration to avoid permission errors when uploading attachments

My instance of vikunjia using docker-compose throws an error (error 500) whenever I upload any attachment (avatar, background, etc). Based on the posts I have seen, this seems to be a permission issue of the files folder in the docker container. What should the compose configuration be to avoid these type of errors?

So far I have:

  api:
    image: vikunja/api
    environment:
      VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: 1

logging into docker container, I see that the files is owned by root.

$ sudo docker exec -it vikunja-api-1 sh
$ ls -alh
-rwxr-xr-x    1 vikunja  root       39.2M Jan 24 17:05 vikunja
drwxr-xr-x    1 vikunja  root        4.0K Jan 24 17:06 .
drwxr-xr-x    2 root     root        4.0K Mar  1 20:43 files

Is there a way to avoid this when setting up vikunjia, other than using chown after the fact? i.e. do I need to add PUID, PGID as follows?

environment:
  VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: 1
  PUID=1000
  PGID=1000

and to fix this issue, do I change ownership of the files folder to chown -R vikunja:root files? or chown -R vikunja:vikunja files?

If it really is a permission issue, there should be a message about it in the logs.

That should work.
I think in your case I’d just set the two variables and then chown -R 1000:1000 the files mount after that.

Thanks, changing the permission of the file mount to vikunja:vikunja works and now I can upload attachments.

However, I wasn’t able to change the compose file to include the PUID/PGID. I tried different ways of entering it and kept throwing me an error.

I tried:

environment:
  VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: 1
  PUID=1000
  PGID=1000

and

environment:
  VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: 1
    - PUID=1000
    - PGID=1000

and

environment:
  VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: 1
  PUID:1000
  PGID:1000

and I kept getting: yaml: line 36: did not find expected key (line 36 is where I enter the PUID)

Try the last config you posted but put a space between : and the numbers.