#!/bin/bash set -e # Install nvm if not already present in the home volume. if [ ! -s "$NVM_DIR/nvm.sh" ]; then echo "nvm not found — running installer..." curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/HEAD/install.sh | NVM_DIR="$NVM_DIR" PROFILE=/dev/null bash echo "nvm installed successfully." fi . "$NVM_DIR/nvm.sh" # Install rbenv + ruby-build if not already present in the home volume. if [ ! -d "$RBENV_ROOT/bin" ]; then echo "rbenv not found — installing..." git clone --depth=1 https://github.com/rbenv/rbenv.git "$RBENV_ROOT" git clone --depth=1 https://github.com/rbenv/ruby-build.git "$RBENV_ROOT/plugins/ruby-build" echo "rbenv installed successfully." fi eval "$(rbenv init - bash)" # Install nvm if not already present in the home volume. if [ ! -s "$NVM_DIR/nvm.sh" ]; then echo "nvm not found — running installer..." curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/HEAD/install.sh | NVM_DIR="$NVM_DIR" PROFILE=/dev/null bash echo "nvm installed successfully." fi . "$NVM_DIR/nvm.sh" # Install Claude Code if not already present in the home volume. # Because the home directory is a volume, this install persists across # container restarts and rebuilds. if ! command -v claude &>/dev/null; then echo "Claude Code not found — running installer..." curl -fsSL https://claude.ai/install.sh | bash echo "Claude Code installed successfully." else echo "Claude Code $(claude --version 2>/dev/null || echo '(version unknown)') ready." fi # Proxy host postgres to 127.0.0.1:5432 inside the container so the app can # use the same DATABASE_URL whether running inside or outside Docker. if ! ss -tlnp 2>/dev/null | grep -q ':5432'; then echo "Starting postgres proxy 127.0.0.1:5432 -> host.docker.internal:5432" socat TCP-LISTEN:5432,bind=127.0.0.1,fork,reuseaddr \ TCP:host.docker.internal:5432 & fi exec "$@"