How to skip uid/gid setup on container boot

The container startup takes a very long time when I’m not using the default user ID 1000 as the entrypoint script tries to update all file permissions in the media folder. This is not necessary since the file ownership is already correct after the first run (unless I change the UID/GID again).

Does anyone have a good way around that problem? If possible I don’t want to change the script since this might cause trouble with future upgrades. Thanks for any ideas!

Pass the environment variable MAYAN_SKIP_CHOWN_ON_STARTUP with a
value of true to skip this process.

Optional. Setting this environment variable to true, will make the entrypoint script skip the initial chwon command on the media folder at /var/lib/mayan.

https://docs.mayan-edms.com/chapters/docker/environment_variables.html#mayan-edms

1 Like

Oops, I should have seen that in the code 🫣

Why do you consider this step still necessary for the non-media folders? Unless the container creates files there before the UID/GID step it should be fine to skip this as well or am I wrong?

EDIT: Never mind I realized that the path is within the container…

However I see that chown is called on /opt/mayan-edms and on /opt/mayan-edms/static. Are there cases where the static folder is not a subfolder of /opt/mayan-edms? Is chown clever enough to see that it has walked the static folder already? Have you tried to speed things up as suggested here: chown only where needed / speedup chown - Unix & Linux Stack Exchange. If not I might give it a go just to see if this would improve things for me. It’s still dead slow to update the file permissions even with the MAYAN_SKIP_CHOWN_ON_STARTUP set to true.

Oops, I should have seen that in the code 🫣

It’s a big codebase, this happens even to us :slight_smile:

Why do you consider this step still necessary for the non-media folders? Unless the container creates files there before the UID/GID step it should be fine to skip this as well or am I wrong?

However I see that chown is called on /opt/mayan-edms and on /opt/mayan-edms/static. Are there cases where the static folder is not a subfolder of /opt/mayan-edms?

Docker support different volume drivers. Some of them set the owner of the top level directory and everything mounted inherits the owner of the volume not the user of the container.

Is chown clever enough to see that it has walked the static folder already?

No idea.

Have you tried to speed things up as suggested here

Will need to be updated to account for user as well as group ownership.

If not I might give it a go just to see if this would improve things for me. It’s still dead slow to update the file permissions even with the MAYAN_SKIP_CHOWN_ON_STARTUP set to true.

Yes please do so and let us know if it results in improvements without adding new artifacts or regressions.