Files
ReachableCEO-AI-Homedir-Public/Docker/RCEO-AIOS-Public-Tools-DocMaker-Base/entrypoint.sh
ReachableCEO d30f103209 Add organized Docker container structure with disciplined naming
- Create layered container architecture: Base, Light, Full, Computational
- Implement non-root user management with UID/GID mapping
- Add Markwhen timeline tool to documentation stack
- Create wrapper scripts for environment variable handling
- Update documentation across all containers
- Establish naming convention using RCEO-AIOS-Public-Tools- prefix
- Add organizational rule to keep repository root clean
- Remove old unorganized container files
2025-10-16 11:40:25 -05:00

49 lines
1.9 KiB
Bash

#!/bin/bash
# entrypoint.sh - Entrypoint script to handle user creation and permission setup at runtime
# Set default values if not provided
USER_ID=${LOCAL_USER_ID:-$(id -u 1000)}
GROUP_ID=${LOCAL_GROUP_ID:-$(id -g 1000)}
# In case the environment variables are not set properly, detect them from the workspace volume
if [ "$USER_ID" = "$(id -u 0)" ] || [ "$USER_ID" = "0" ]; then
# Detect the UID and GID of the user that owns the workspace directory
if [ -d "/workspace" ]; then
USER_ID=$(stat -c %u /workspace 2>/dev/null || echo 1000)
GROUP_ID=$(stat -c %g /workspace 2>/dev/null || echo 1000)
else
USER_ID=${LOCAL_USER_ID:-1000}
GROUP_ID=${LOCAL_GROUP_ID:-1000}
fi
fi
echo "Starting with USER_ID=$USER_ID and GROUP_ID=$GROUP_ID"
# Create the group with specified GID
groupadd -f -g $GROUP_ID -o ReachableCEO-Tools 2>/dev/null || groupmod -g $GROUP_ID -o ReachableCEO-Tools
# Create the user with specified UID and add to the group
useradd -f -u $USER_ID -g $GROUP_ID -m -s /bin/bash -o ReachableCEO-Tools 2>/dev/null || usermod -u $USER_ID -g $GROUP_ID -o ReachableCEO-Tools
# Add user to sudo group for any necessary operations
usermod -aG sudo ReachableCEO-Tools 2>/dev/null || true
# Make sure workspace directory exists and has proper permissions
mkdir -p /workspace
chown -R $USER_ID:$GROUP_ID /workspace
# Set up proper permissions for Rust and Cargo (if they exist)
mkdir -p /home/ReachableCEO-Tools/.cargo
chown $USER_ID:$GROUP_ID /home/ReachableCEO-Tools/.cargo
# Set up proper permissions for npm global packages (if they exist)
mkdir -p /home/ReachableCEO-Tools/.npm
chown $USER_ID:$GROUP_ID /home/ReachableCEO-Tools/.npm
# If there are additional arguments, run them as the created user
if [ $# -gt 0 ]; then
exec su -p ReachableCEO-Tools -c "$*"
else
# Otherwise start an interactive bash shell as the created user
exec su -p ReachableCEO-Tools -c "/bin/bash"
fi