Files
opencode-manager/scripts/docker-entrypoint.sh
T
Chris Scott 81a66d2ddb Add single-user authentication system with Better Auth integration (#76)
* Add Better Auth integration with session management

- Implement user authentication using Better Auth library
- Add login, register, and sign out functionality
- Support passkey/WebAuthn authentication
- Create database schema for users, sessions, accounts, passkeys
- Add AuthProvider context and ProtectedRoute components
- Add account settings page in settings dialog
- Protect all API routes with authentication middleware
- Update environment configuration for auth providers

* Add single-user authentication system with admin setup

- Add first-run Setup page for initial admin account creation
- Add environment-based admin configuration (ADMIN_EMAIL, ADMIN_PASSWORD)
- Add password reset capability via ADMIN_PASSWORD_RESET environment flag
- Migrate to data routers with auth loaders, remove ProtectedRoute
- Add change password functionality to account settings
- Enforce AUTH_SECRET requirement in production
- Auto-disable registration when admin is pre-configured via environment

* Track busy/idle session status across hooks

* Bump version to 0.7.5

* Update pnpm to 10.28.1
2026-01-24 17:45:44 -05:00

80 lines
2.3 KiB
Bash

#!/bin/bash
set -e
export HOME=/home/node
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$HOME/.opencode/bin:/usr/local/bin:$PATH"
echo "🔍 Checking Bun installation..."
if ! command -v bun >/dev/null 2>&1; then
echo "❌ Bun not found. Installing..."
curl -fsSL https://bun.sh/install | bash
if ! command -v bun >/dev/null 2>&1; then
echo "❌ Failed to install Bun. Exiting."
exit 1
fi
echo "✅ Bun installed successfully"
else
BUN_VERSION=$(bun --version 2>&1 || echo "unknown")
echo "✅ Bun is installed (version: $BUN_VERSION)"
fi
echo "🔍 Checking OpenCode installation..."
MIN_OPENCODE_VERSION="1.0.137"
version_gte() {
printf '%s\n%s\n' "$2" "$1" | sort -V -C
}
if ! command -v opencode >/dev/null 2>&1; then
echo "⚠️ OpenCode not found. Installing..."
curl -fsSL https://opencode.ai/install | bash
if ! command -v opencode >/dev/null 2>&1; then
echo "❌ Failed to install OpenCode. Exiting."
exit 1
fi
echo "✅ OpenCode installed successfully"
fi
OPENCODE_VERSION=$(opencode --version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "unknown")
echo "✅ OpenCode is installed (version: $OPENCODE_VERSION)"
if [ "$OPENCODE_VERSION" != "unknown" ]; then
if version_gte "$OPENCODE_VERSION" "$MIN_OPENCODE_VERSION"; then
echo "✅ OpenCode version meets minimum requirement (>=$MIN_OPENCODE_VERSION)"
else
echo "⚠️ OpenCode version $OPENCODE_VERSION is below minimum required version $MIN_OPENCODE_VERSION"
echo "🔄 Upgrading OpenCode..."
opencode upgrade || curl -fsSL https://opencode.ai/install | bash
OPENCODE_VERSION=$(opencode --version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "unknown")
echo "✅ OpenCode upgraded to version: $OPENCODE_VERSION"
fi
fi
echo "🚀 Starting OpenCode Manager Backend..."
if [ -z "$AUTH_SECRET" ]; then
echo "❌ AUTH_SECRET is required but not set"
echo ""
echo "Please set AUTH_SECRET environment variable with a secure random string."
echo "Generate one with: openssl rand -base64 32"
echo ""
echo "Example in docker-compose.yml:"
echo " environment:"
echo " - AUTH_SECRET=your-secure-random-secret-here"
echo ""
echo "Example with Docker run:"
echo " docker run -e AUTH_SECRET=\$(openssl rand -base64 32) ..."
echo ""
exit 1
fi
exec "$@"