#!/bin/sh set -e # Define the user ID in the environment variable USER_ID with a default value ARG USER_ID=1000 ENV USER_ID=$USER_ID # Check if the user already exists if id "$USER_ID" >/dev/null 2>&1; then echo "User with ID $USER_ID already exists." else echo "Creating user with ID $USER_ID." useradd -m -u "$USER_ID" user fi # Set appropriate permissions for the application directory chown -R user:user /app chmod -R 755 /app # Print environment variables for debugging echo "USER_ID: $USER_ID" # Execute the main command exec "$@"