Skip to content

Instantly share code, notes, and snippets.

@darinkishore
Last active May 31, 2025 21:53
Show Gist options
  • Save darinkishore/cba73a811392ba6cc5f1ed75f4048b7c to your computer and use it in GitHub Desktop.
Save darinkishore/cba73a811392ba6cc5f1ed75f4048b7c to your computer and use it in GitHub Desktop.
One-command setup script for SF Compute containers - installs dev tools, mise, uv, Node.js, and Claude Code
#!/bin/bash
# Robust setup script that works in minimal containers
# Works even without sudo pre-installed
set -e
echo "πŸš€ Starting dev environment setup..."
# First, ensure we're running as root
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root (or with sudo if available)"
exit 1
fi
echo "πŸ“¦ Installing base packages..."
# Update package list
apt-get update
# Install essential packages first (including sudo)
apt-get install -y \
sudo \
curl \
wget \
ca-certificates \
gnupg \
lsb-release
# Now install all other packages
echo "πŸ“¦ Installing development packages..."
apt-get install -y \
git gh openssh-client \
build-essential pkg-config cmake \
software-properties-common \
fish zsh \
python3 python3-pip python3-venv \
libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
libsqlite3-dev libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev \
unzip jq tmux htop ncdu tree
echo "πŸ‘€ Setting up developer user..."
# Create user if not exists
if ! id -u developer >/dev/null 2>&1; then
useradd -m -s /bin/bash developer # Use bash initially
echo "developer ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Create necessary directories
mkdir -p /home/developer/.local/bin
mkdir -p /home/developer/.config
chown -R developer:developer /home/developer
fi
# Create setup script for developer user
cat << 'DEVSETUP' > /tmp/developer-setup.sh
#!/bin/bash
set -e
echo "πŸ”§ Installing development tools as developer..."
# Ensure .local/bin exists and is in PATH
mkdir -p ~/.local/bin
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
# Install mise
echo "Installing mise..."
curl -fsSL https://mise.run | sh
echo 'eval "$($HOME/.local/bin/mise activate bash)"' >> ~/.bashrc
# Source bashrc to get mise in PATH
source ~/.bashrc
# Install uv
echo "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install tools using direct downloads
echo "Installing ripgrep and fd..."
cd /tmp
# Ripgrep
if ! command -v rg &> /dev/null; then
curl -LO https://github.com/BurntSushi/ripgrep/releases/download/14.1.0/ripgrep_14.1.0-1_amd64.deb
sudo dpkg -i ripgrep_14.1.0-1_amd64.deb || true
sudo apt-get install -f -y # Fix any dependency issues
fi
# fd
if ! command -v fd &> /dev/null; then
curl -LO https://github.com/sharkdp/fd/releases/download/v9.0.0/fd_9.0.0_amd64.deb
sudo dpkg -i fd_9.0.0_amd64.deb || true
sudo apt-get install -f -y # Fix any dependency issues
fi
# Install Node via mise
echo "Installing Node.js..."
~/.local/bin/mise use -g node@22
~/.local/bin/mise install
# Install Claude Code
echo "Installing Claude Code..."
~/.local/share/mise/shims/npm install -g @anthropic-ai/claude-code || \
~/.local/share/mise/shims/npm install -g @anthropic-ai/claude-code --force
# Install Helix editor
echo "Installing Helix editor..."
cd /tmp
curl -LO https://github.com/helix-editor/helix/releases/download/23.10/helix-23.10-x86_64-linux.tar.xz
tar -xf helix-23.10-x86_64-linux.tar.xz
mkdir -p ~/.local/bin
cp helix-23.10-x86_64-linux/hx ~/.local/bin/
mkdir -p ~/.config/helix
cp -r helix-23.10-x86_64-linux/runtime ~/.config/helix/
# Configure git
git config --global init.defaultBranch main || true
git config --global core.editor hx || true
# Setup fish shell if desired
if command -v fish &> /dev/null; then
echo "Setting up fish shell..."
mkdir -p ~/.config/fish
echo 'set -gx PATH $HOME/.local/bin $PATH' >> ~/.config/fish/config.fish
echo '$HOME/.local/bin/mise activate fish | source' >> ~/.config/fish/config.fish
# Change default shell to fish
sudo chsh -s $(which fish) developer || true
fi
# Clean up
cd ~
rm -rf /tmp/*.deb /tmp/helix-*
echo "βœ… Developer setup complete!"
DEVSETUP
chmod +x /tmp/developer-setup.sh
# Run as developer user
echo "πŸš€ Running developer setup..."
su - developer -c "bash /tmp/developer-setup.sh"
# Cleanup
rm -f /tmp/developer-setup.sh
echo ""
echo "βœ… Setup complete! Your environment is ready."
echo ""
echo "To use your new environment:"
echo " su - developer"
echo ""
echo "Installed tools:"
echo " β€’ Fish shell (default)"
echo " β€’ Helix editor (hx)"
echo " β€’ Development tools (ripgrep, fd)"
echo " β€’ Node.js 22 (via mise)"
echo " β€’ Python with uv"
echo " β€’ Claude Code CLI"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment