rr- / szurubooru

Image board engine, Danbooru-style.
GNU General Public License v3.0
665 stars 175 forks source link

Backend using deprecated .dockerenv-file to test if run in container #622

Open phil-flip opened 7 months ago

phil-flip commented 7 months ago

I personally use Szuru on K3S in TrueNAS scale. They recently switched from Docker to another containing engine for K3S to run on. Not sure what it exactly is, but Szuru was not happy and in the process the Szuru backend kinda do the die. It was lacking the .dockerenv-file at https://github.com/rr-/szurubooru/blob/190d79542676bf8c83481198c849176fadb8e6ae/server/szurubooru/config.py#L60 causing the code to think it is not being run in docker and try to use the Env-Vars database, data_url and data_dir, which aren't set on my Szuru serverconfig.

From what I have read online it is a common way to check, if the code is being run in Docker. But there is also not much documentation bout it. Some say it is a deprecated file which was created alongside .dockerinitfor the LXC execution driver. A different and more future-proof way of doing it, would be to check for the env var that docker or any other containing solution sets or set your own flag with it.

The fix for now what to mount an empty .dockerenv-file at where the code above what's it to be.