Download entrypoint.sh from ummmar/cloudcode: direct link, hf CLI and curl.
- Browser
- Download file 2.69 kB
-
https://huggingface.co/spaces/ummmar/cloudcode/resolve/main/entrypoint.sh
- Command line
-
hf download hf://spaces/ummmar/cloudcode/entrypoint.sh
-
curl -L -o entrypoint.sh https://huggingface.co/spaces/ummmar/cloudcode/resolve/main/entrypoint.sh
2.69 kB
| set -e | |
| echo "===== Application Startup at $(date) =====" | |
| # β‘ HEALTH SERVER FIRST β prevents HF timeout | |
| python /health_server.py & | |
| # 1. Git Credentials | |
| if [ -n "$GITHUB_TOKEN" ] && [ -n "$GITHUB_USER" ]; then | |
| git config --global credential.helper store | |
| git config --global user.name "$GITHUB_USER" | |
| git config --global user.email "$GITHUB_USER@users.noreply.github.com" | |
| echo "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com" > ~/.git-credentials | |
| echo "β Git credentials configured." | |
| fi | |
| # 2. Environment & Dirs | |
| export XDG_CONFIG_HOME="/workspace/config" | |
| export XDG_DATA_HOME="/workspace/data" # β ADD THIS | |
| export OPENCODE_CONFIG_DIR="/workspace/config/opencode" | |
| export OPENCHAMBER_UI_PASSWORD="${GATEWAY_TOKEN:-changeme}" | |
| mkdir -p $OPENCODE_CONFIG_DIR $XDG_DATA_HOME /workspace/projects | |
| # ... rest of entrypoint.sh ... | |
| mkdir -p $OPENCODE_CONFIG_DIR /workspace/projects | |
| # 3. Wrangler Config | |
| if [ -n "$CLOUDFLARE_API_TOKEN" ]; then | |
| mkdir -p ~/.wrangler/config | |
| cat << EOF > ~/.wrangler/config/default.toml | |
| api_token = "$CLOUDFLARE_API_TOKEN" | |
| EOF | |
| echo "β Wrangler configured." | |
| fi | |
| # 4. LLM Keys | |
| if [ -n "$LLM_API_KEY" ]; then | |
| export OPENROUTER_API_KEY="$LLM_API_KEY" | |
| export ANTHROPIC_API_KEY="$LLM_API_KEY" | |
| export OPENAI_API_KEY="$LLM_API_KEY" | |
| export GOOGLE_API_KEY="$LLM_API_KEY" | |
| export GEMINI_API_KEY="$LLM_API_KEY" | |
| export DEEPSEEK_API_KEY="$LLM_API_KEY" | |
| fi | |
| export OPENCODE_DEFAULT_MODEL="${LLM_MODEL:-openrouter/anthropic/claude-sonnet-4}" | |
| # 5. Restore Workspace (now safe from HF timeout) | |
| python /restore_workspace.py | |
| # 6. Package Replay | |
| touch /workspace/config/startup.sh | |
| chmod +x /workspace/config/startup.sh | |
| if ! grep -q "workspace/config/startup.sh" ~/.bashrc 2>/dev/null; then | |
| cat << 'EOF' >> ~/.bashrc | |
| pip() { command pip "$@" && echo "pip $*" >> /workspace/config/startup.sh; } | |
| npm() { command npm "$@" && echo "npm $*" >> /workspace/config/startup.sh; } | |
| apt() { command apt "$@" && echo "apt $*" >> /workspace/config/startup.sh; } | |
| EOF | |
| fi | |
| echo "π¦ Replaying persistent packages..." | |
| bash /workspace/config/startup.sh 2>/dev/null || true | |
| # 7. Startup Vars | |
| [ -n "$OPENCODE_APT_PACKAGES" ] && apt-get update && apt-get install -y $OPENCODE_APT_PACKAGES | |
| [ -n "$OPENCODE_RUN" ] && bash -c "$OPENCODE_RUN" | |
| # 8. Background Services | |
| [ -n "$MY_HF_TOKEN" ] && [ -n "$HF_DATASET_REPO" ] && python /sync_workspace.py & | |
| [ -n "$CLOUDFLARE_API_TOKEN" ] && [ -n "$CF_ACCOUNT_ID" ] && python /keep_alive.py & | |
| # Launch OpenChamber (daemon mode) + keep container alive | |
| cd /workspace/projects | |
| echo "π Starting OpenChamber on port 7860..." | |
| openchamber --port 7860 --host 0.0.0.0 | |
| sleep infinity |