Testcontainers and permissions issue on OSX
We use testcontainers to easily do integration tests that depend on other services.
It makes it easy to spin up docker container in your tests. With Quarkus it is even simpeler because it supports testcontainers out of the box.
Unfortunately I kept getting an issue with running the mariadb container.
As soon as the test starts after a few seconds the mariadb gets shutdown again.
After checking the log of the shutdown container I found that it didn't have permission to read the my.cnf file.
I was really stuck, I had no clue but after searching I found this nice post talking about permissions.
This got me thinking because I have set umask pretty strict because of security reasons. Here is a nice post that explains it. Mine is set to 027.
After setting the umask to 011 I still had the same issue.
When I do a:
/tmp> ls -la
total 208
drwxrwxrwt 20 root wheel 640 Feb 16 12:10 ./
drwxr-xr-x 6 root wheel 192 Jan 1 2020 ../
drwxr-x--- 3 logic wheel 96 Feb 16 12:09 .testcontainers-tmp-379975470819841649/
As you can see, the settings are still wrong. Then it hit me, gradle is running as a daemon. You need to restart the daemon to pick up the new umask settings.
This fixed it :
drwxrw-rw- 3 logic wheel 96 Feb 16 12:14 .testcontainers-tmp-14701789202178352376/
drwxrw-rw- 3 logic wheel 96 Feb 16 12:14 .testcontainers-tmp-2461134091080897801/
So now I have a zsh function that will alter the umask when I run gradle.