Add entrypoint to fix volume permissions at runtime

This commit is contained in:
2025-10-13 18:49:38 +02:00
parent 632ef4c812
commit 69ca3de2d1
2 changed files with 29 additions and 8 deletions

15
entrypoint.sh Normal file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
# This script ensures that the 'data' directory is owned by the 'appuser'
# before the main application starts. This is crucial when using Docker volumes,
# as the mounted directory from the host will be owned by root inside the container.
# Set the ownership of the data directory to the non-root user.
# The '-R' flag makes it recursive.
chown -R appuser:appgroup /usr/src/app/data
# Execute the main command (passed as arguments to this script)
# as the non-root user 'appuser'.
# 'su-exec' is a lightweight tool to switch users.
# "$@" passes all arguments from the CMD line.
exec su-exec appuser "$@"