ummmar commited on
Commit
10afeb1
·
verified ·
1 Parent(s): 88a02ec

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +11 -29
entrypoint.sh CHANGED
@@ -1,17 +1,7 @@
1
  #!/bin/bash
2
  set -e
3
 
4
- # Fallback: Explicitly tell OpenChamber where the binary is
5
- export OPENCODE_BINARY="/root/.local/bin/opencode"
6
- if [ ! -f "$OPENCODE_BINARY" ]; then
7
- # Auto-detect if it ended up somewhere else
8
- export OPENCODE_BINARY=$(find / -name "opencode" -executable -type f 2>/dev/null | head -n 1)
9
- fi
10
-
11
- # 1. Inject Git Credentials
12
- # ... (keep the rest of your existing entrypoint.sh exactly the same)
13
-
14
- # 1. Git Credentials
15
  if [ -n "$GITHUB_TOKEN" ] && [ -n "$GITHUB_USER" ]; then
16
  git config --global credential.helper store
17
  git config --global user.name "$GITHUB_USER"
@@ -19,38 +9,30 @@ if [ -n "$GITHUB_TOKEN" ] && [ -n "$GITHUB_USER" ]; then
19
  echo "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com" > ~/.git-credentials
20
  fi
21
 
22
- # 2. Environment & Directories
23
  export XDG_CONFIG_HOME="/workspace/config"
24
  export OPENCODE_CONFIG_DIR="/workspace/config/opencode"
 
 
25
  mkdir -p $OPENCODE_CONFIG_DIR /workspace/projects
26
- touch /workspace/config/startup.sh
27
- chmod +x /workspace/config/startup.sh
28
 
29
- # 3. Ephemeral Package Replay (Wrappers for terminal)
30
  cat << 'EOF' >> ~/.bashrc
31
  pip() { command pip "$@" && echo "pip $*" >> /workspace/config/startup.sh; }
32
  npm() { command npm "$@" && echo "npm $*" >> /workspace/config/startup.sh; }
33
  apt() { command apt "$@" && echo "apt $*" >> /workspace/config/startup.sh; }
34
  EOF
35
 
36
- # 4. Replay previously installed packages
37
- echo "Replaying persistent packages..."
38
  bash /workspace/config/startup.sh || true
39
 
40
- # 5. Run Startup Variables
41
  [ -n "$OPENCODE_APT_PACKAGES" ] && apt-get update && apt-get install -y $OPENCODE_APT_PACKAGES
42
  [ -n "$OPENCODE_RUN" ] && bash -c "$OPENCODE_RUN"
43
 
44
- # 6. Start Background Services
45
- python /health_server.py &
46
- python /sync_config.py &
47
- python /keep_alive.py &
48
 
49
- # 7. Self-Healing Gateway (Auto-restarts OpenChamber if it crashes)
50
  cd /workspace/projects
51
- echo "Starting OpenChamber..."
52
- while true; do
53
- PORT=7860 openchamber --host 0.0.0.0
54
- echo "OpenChamber exited with code $?. Restarting in 5 seconds..."
55
- sleep 5
56
- done
 
1
  #!/bin/bash
2
  set -e
3
 
4
+ # Git Credentials
 
 
 
 
 
 
 
 
 
 
5
  if [ -n "$GITHUB_TOKEN" ] && [ -n "$GITHUB_USER" ]; then
6
  git config --global credential.helper store
7
  git config --global user.name "$GITHUB_USER"
 
9
  echo "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com" > ~/.git-credentials
10
  fi
11
 
12
+ # Environment
13
  export XDG_CONFIG_HOME="/workspace/config"
14
  export OPENCODE_CONFIG_DIR="/workspace/config/opencode"
15
+ export OPENCHAMBER_UI_PASSWORD="${GATEWAY_TOKEN:-changeme}"
16
+ export OPENCODE_BINARY="/root/.local/bin/opencode"
17
  mkdir -p $OPENCODE_CONFIG_DIR /workspace/projects
 
 
18
 
19
+ # Package replay wrappers
20
  cat << 'EOF' >> ~/.bashrc
21
  pip() { command pip "$@" && echo "pip $*" >> /workspace/config/startup.sh; }
22
  npm() { command npm "$@" && echo "npm $*" >> /workspace/config/startup.sh; }
23
  apt() { command apt "$@" && echo "apt $*" >> /workspace/config/startup.sh; }
24
  EOF
25
 
26
+ # Replay packages
 
27
  bash /workspace/config/startup.sh || true
28
 
29
+ # Startup vars
30
  [ -n "$OPENCODE_APT_PACKAGES" ] && apt-get update && apt-get install -y $OPENCODE_APT_PACKAGES
31
  [ -n "$OPENCODE_RUN" ] && bash -c "$OPENCODE_RUN"
32
 
33
+ # Start config sync
34
+ [ -n "$HF_TOKEN" ] && [ -n "$HF_DATASET_REPO" ] && python /sync_config.py &
 
 
35
 
36
+ # Launch OpenChamber (foreground)
37
  cd /workspace/projects
38
+ exec openchamber --port 7860 --host 0.0.0.0