#!/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 "$@"