Skip to content

Commit aa1bf04

Browse files
committed
fix: deploy to /opt/nanoclaw instead of user home directory
Eliminates cross-user permission issues by using a shared /opt path. Removes sudo wrapper and sg docker — root operates directly. Auto-clones repo on first deploy. Hardcodes config path.
1 parent 3e54a43 commit aa1bf04

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

.github/workflows/deploy.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,24 @@ jobs:
2020
username: ${{ secrets.VM_USER }}
2121
key: ${{ secrets.VM_SSH_KEY }}
2222
fingerprint: ${{ secrets.VM_HOST_FINGERPRINT }}
23-
envs: DOTENV,DEPLOY_DIR,GITHUB_SHA
23+
envs: DOTENV,GITHUB_SHA
2424
script: |
2525
set -eo pipefail
26-
export DEPLOY_DIR GITHUB_SHA DOTENV
27-
sudo --preserve-env=DEPLOY_DIR,GITHUB_SHA,DOTENV -iu luc_minitap_ai bash <<'DEPLOY'
28-
set -eo pipefail
26+
DEPLOY_DIR=/opt/nanoclaw
27+
if [ ! -d "$DEPLOY_DIR/.git" ]; then
28+
git init "$DEPLOY_DIR"
29+
git -C "$DEPLOY_DIR" remote add origin https://github.com/${{ github.repository }}.git
30+
fi
2931
cd "$DEPLOY_DIR"
3032
install -m 600 /dev/null .env
3133
printf '%s\n' "$DOTENV" > .env
3234
unset DOTENV
3335
git fetch --prune origin
3436
git reset --hard "$GITHUB_SHA"
35-
sg docker -c '
36-
docker build -t nanoclaw:latest . &&
37-
docker build -t nanoclaw-agent:latest -f container/Dockerfile container/ &&
38-
docker compose up -d --remove-orphans
39-
'
40-
DEPLOY
37+
docker build -t nanoclaw:latest .
38+
docker build -t nanoclaw-agent:latest -f container/Dockerfile container/
39+
docker compose up -d --remove-orphans
4140
script_stop: true
4241
env:
4342
DOTENV: ${{ secrets.DOTENV }}
44-
DEPLOY_DIR: ${{ vars.DEPLOY_DIR || '~/nanoclaw' }}
4543
GITHUB_SHA: ${{ github.sha }}

CLAUDE.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,50 @@ Single Node.js process with skill-based channel system. Channels (WhatsApp, Tele
88

99
## Key Files
1010

11-
| File | Purpose |
12-
|------|---------|
13-
| `src/index.ts` | Orchestrator: state, message loop, agent invocation |
14-
| `src/channels/registry.ts` | Channel registry (self-registration at startup) |
15-
| `src/ipc.ts` | IPC watcher and task processing |
16-
| `src/router.ts` | Message formatting and outbound routing |
17-
| `src/config.ts` | Trigger pattern, paths, intervals |
18-
| `src/container-runner.ts` | Spawns agent containers with mounts |
19-
| `src/task-scheduler.ts` | Runs scheduled tasks |
20-
| `src/db.ts` | SQLite operations |
21-
| `groups/{name}/CLAUDE.md` | Per-group memory (isolated) |
11+
| File | Purpose |
12+
| ----------------------------------- | ---------------------------------------------------------- |
13+
| `src/index.ts` | Orchestrator: state, message loop, agent invocation |
14+
| `src/channels/registry.ts` | Channel registry (self-registration at startup) |
15+
| `src/ipc.ts` | IPC watcher and task processing |
16+
| `src/router.ts` | Message formatting and outbound routing |
17+
| `src/config.ts` | Trigger pattern, paths, intervals |
18+
| `src/container-runner.ts` | Spawns agent containers with mounts |
19+
| `src/task-scheduler.ts` | Runs scheduled tasks |
20+
| `src/db.ts` | SQLite operations |
21+
| `groups/{name}/CLAUDE.md` | Per-group memory (isolated) |
2222
| `container/skills/agent-browser.md` | Browser automation tool (available to all agents via Bash) |
2323

2424
## Skills
2525

26-
| Skill | When to Use |
27-
|-------|-------------|
28-
| `/setup` | First-time installation, authentication, service configuration |
29-
| `/customize` | Adding channels, integrations, changing behavior |
30-
| `/debug` | Container issues, logs, troubleshooting |
31-
| `/update-nanoclaw` | Bring upstream NanoClaw updates into a customized install |
32-
| `/qodo-pr-resolver` | Fetch and fix Qodo PR review issues interactively or in batch |
33-
| `/get-qodo-rules` | Load org- and repo-level coding rules from Qodo before code tasks |
26+
| Skill | When to Use |
27+
| ------------------- | ----------------------------------------------------------------- |
28+
| `/setup` | First-time installation, authentication, service configuration |
29+
| `/customize` | Adding channels, integrations, changing behavior |
30+
| `/debug` | Container issues, logs, troubleshooting |
31+
| `/update-nanoclaw` | Bring upstream NanoClaw updates into a customized install |
32+
| `/qodo-pr-resolver` | Fetch and fix Qodo PR review issues interactively or in batch |
33+
| `/get-qodo-rules` | Load org- and repo-level coding rules from Qodo before code tasks |
3434

3535
## Deployment
3636

37-
Production runs on a GCP VM (`nanoclaw` in `europe-west9-a`, project `minitap-sandbox`) as a Docker container at `~/nanoclaw`.
37+
Production runs on a GCP VM (`nanoclaw` in `europe-west9-a`, project `minitap-sandbox`) as a Docker container at `/opt/nanoclaw`.
3838

3939
Architecture: NanoClaw host container spawns agent containers as siblings via Docker socket mount (not Docker-in-Docker). `HOST_PROJECT_ROOT` env var maps container paths to host paths for volume mounts.
4040

41+
Deployments are automated via GitHub Actions on push to `main`. See `.github/workflows/deploy.yml`.
42+
4143
```bash
42-
# Deploy changes
43-
gcloud compute ssh luc_minitap_ai@nanoclaw --zone=europe-west9-a --project=minitap-sandbox --command="cd ~/nanoclaw && sudo git pull && sg docker -c 'docker build -t nanoclaw:latest . && docker compose down && docker compose up -d'"
44+
# Manual deploy (prefer pushing to main instead)
45+
gcloud compute ssh luc_minitap_ai@nanoclaw --zone=europe-west9-a --project=minitap-sandbox --command="cd /opt/nanoclaw && sudo git pull && sudo docker build -t nanoclaw:latest . && sudo docker compose up -d --remove-orphans"
4446

4547
# Rebuild agent container
46-
gcloud compute ssh luc_minitap_ai@nanoclaw --zone=europe-west9-a --project=minitap-sandbox --command="cd ~/nanoclaw && sg docker -c 'docker build -t nanoclaw-agent:latest -f container/Dockerfile container/'"
48+
gcloud compute ssh luc_minitap_ai@nanoclaw --zone=europe-west9-a --project=minitap-sandbox --command="cd /opt/nanoclaw && sudo docker build -t nanoclaw-agent:latest -f container/Dockerfile container/"
4749

4850
# Check logs
49-
gcloud compute ssh luc_minitap_ai@nanoclaw --zone=europe-west9-a --project=minitap-sandbox --command="sg docker -c 'docker logs nanoclaw --tail 30'"
51+
gcloud compute ssh luc_minitap_ai@nanoclaw --zone=europe-west9-a --project=minitap-sandbox --command="sudo docker logs nanoclaw --tail 30"
5052

5153
# Restart
52-
gcloud compute ssh luc_minitap_ai@nanoclaw --zone=europe-west9-a --project=minitap-sandbox --command="sg docker -c 'cd ~/nanoclaw && docker compose restart'"
54+
gcloud compute ssh luc_minitap_ai@nanoclaw --zone=europe-west9-a --project=minitap-sandbox --command="cd /opt/nanoclaw && sudo docker compose restart"
5355
```
5456

5557
Key files: `Dockerfile` (host image), `docker-compose.yml` (compose config), `.dockerignore`.

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ services:
1414
- ./container:/app/container
1515
# .env file — app reads it directly via readEnvFile() for secrets
1616
- ./.env:/app/.env:ro
17-
# Security config (mount/sender allowlists) — stored outside project root
18-
- ~/.config/nanoclaw:/root/.config/nanoclaw:ro
17+
# Security config (mount/sender allowlists)
18+
- /opt/nanoclaw/config:/root/.config/nanoclaw:ro
1919
env_file:
2020
- .env
2121
environment:

0 commit comments

Comments
 (0)