Pre-install server deps for fast devcontainer start. Fix dev launch.json

There seems to be a more standard mechanism of specifying launch.json
params for devcontainers. Previous mechanism to write launch.json to
.vscode/launch.json in post creation step does not work.

Improve default launch.json to include khoj admin username, password
with placeholder values to get started with local development faster.

Define dockerfile for devcontainer to pre-built server, web app
dependencies during dev container image creation stage. So install on
dev container startup is sped up as no need to install dependencies.
This commit is contained in:
Debanjum
2025-06-03 01:23:19 -07:00
parent f3a5fe1ae8
commit 50f37d541a
4 changed files with 78 additions and 79 deletions

View File

@@ -2,19 +2,14 @@
# ---
PROJECT_ROOT=$(git rev-parse --show-toplevel)
# Default is a minimal, local installation unless config flags are set.
# Default to minimal installation unless --full flag passed
INSTALL_FULL=false
DEVCONTAINER=false
for arg in "$@"
do
if [ "$arg" == "--full" ]
then
INSTALL_FULL=true
fi
if [ "$arg" == "--devcontainer" ]
then
DEVCONTAINER=true
fi
done
# Install Server App
@@ -28,7 +23,7 @@ python3 -m venv .venv && . .venv/bin/activate && python3 -m pip install -e '.[de
# ---
echo "Installing Web App..."
cd $PROJECT_ROOT/src/interface/web
yarn install
yarn install && yarn export
# Install Obsidian App
# ---
@@ -46,74 +41,6 @@ if [ "$INSTALL_FULL" = true ] ; then
yarn install
fi
# Create .vscode/launch.json if it doesn't exist
# ---
VSCODE_DIR="$PROJECT_ROOT/.vscode"
LAUNCH_JSON_PATH="$VSCODE_DIR/launch.json"
# Overwrite project vscode launch.json in devcontainer
# ---
# Differs from default launch.json with sudo true.
# Required by pgserver in github codespaces, not in local dev.
mkdir -p "$VSCODE_DIR"
if [ "$DEVCONTAINER" = true ]; then
echo "Creating $LAUNCH_JSON_PATH..."
cat << EOF > "$LAUNCH_JSON_PATH"
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Khoj",
"type": "debugpy",
"request": "launch",
"module": "src.khoj.main",
"justMyCode": false,
"console": "integratedTerminal",
"sudo": true,
"args": [
"-v",
"--anonymous-mode",
"--non-interactive",
"--port=42110",
],
// You can load environment variables via a .env file, the env field below or Github Codespace secrets.
"envFile": "\${workspaceFolder}/.env",
"env": {
"KHOJ_ADMIN_EMAIL": "admin",
"KHOJ_ADMIN_PASSWORD": "admin",
"USE_EMBEDDED_DB": "True",
"KHOJ_DEBUG": "True",
"KHOJ_TELEMETRY_DISABLE": "True",
// Set LLM Provider API keys
// ---
// "GEMINI_API_KEY": "",
// "ANTHROPIC_API_KEY": "",
// "OPENAI_API_KEY": "",
// "OPENAI_BASE_URL": "http://localhost:11434/v1/",
// "KHOJ_DEFAULT_CHAT_MODEL": "claude-sonnet-4-0",
// Set Search Provider API keys
// ---
// "SERPER_DEV_API_KEY": "",
// "OLOSTEP_API_KEY": "",
// "FIRECRAWL_API_KEY": "",
// "JINA_API_KEY": "",
// Enable Khoj Operator
// ---
// "KHOJ_OPERATOR_ENABLED": "True",
// Configure Code Sandbox
// ---
// "KHOJ_TERRARIUM_URL": "http://localhost:8080",
// "E2B_API_KEY": "",
// Enable Promptracer to debug prompt flows
// ---
// "PROMPTRACE_DIR": "\${workspaceFolder}/promptrace",
}
},
]
}
EOF
fi
# Install pre-commit hooks
# ----
echo "Installing pre-commit hooks..."