@ekevu123
if you have a startup.sh or other launch script, it is common to have the script touch /app/data/initialized during first setup, all setup inside a test whether .initialized is present or not.
If so, skip setup.
If not, then do setup.
Setup including key generation.
I haven't reviewed how you launch the app, so not sure how viable it is for you, but it's very common for other apps.
if [ ! -f /app/data/.initialized ]; then
cp -a -n /app/code/defaults/config/. /app/data/config/ || true
touch /app/data/.initialized
fi