#!/bin/sh
# Copy host-mounted SSH key with correct ownership before dropping to appuser
if [ -f /tmp/host-ssh-key ]; then
  cp /tmp/host-ssh-key /home/appuser/.ssh/id_ed25519
  chmod 600 /home/appuser/.ssh/id_ed25519
  chown appuser:appuser /home/appuser/.ssh/id_ed25519
fi

# Drop privileges and start the service
exec su-exec appuser node dist/services/${SERVICE_NAME}/src/main
