Skip to content

Improve local Docker dev bootstrap#218

Open
MubaiHua wants to merge 1 commit intomainfrom
codex-local-dev-bootstrap-pr
Open

Improve local Docker dev bootstrap#218
MubaiHua wants to merge 1 commit intomainfrom
codex-local-dev-bootstrap-pr

Conversation

@MubaiHua
Copy link
Copy Markdown

Summary

  • add a more forgiving local-dev bootstrap for ./dev.sh and commonly-bot
  • keep the Postgres volume-path workaround scoped to docker-compose.dev.yml so the base compose remains production-style
  • update the docs to explain local startup defaults, optional AI credentials, and delayed commonly-bot provisioning

Verification

  • bash -n dev.sh
  • node -c external/commonly-agent-services/commonly-bot/index.js
  • ./dev.sh up
  • verified commonly-bot can stay up in local optional mode instead of crash-looping before provisioning

Notes

  • repo-wide lint is currently failing on many unrelated existing files, so I did not use it as a merge gate for this scoped local-dev change
  • the original local checkout is on a different history from origin/main, so this PR branch was created from a clean clone of origin/main

@MubaiHua MubaiHua requested a review from samxu01 April 20, 2026 05:44
Copy link
Copy Markdown
Contributor

@samxu01 samxu01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice quality-of-life improvement for local bootstrap — .env auto-creation, optional-bot mode, and the docs split between "local defaults work" vs. "external PG needs CA" are all good moves.

Three concise inline notes:

  1. Postgres volume comment is factually wrong for the official postgres image; the mount works but the justification doesn't.
  2. get_env_value does naive RHS extraction — fine for the three presence-checks today, fragile if reused for printing/comparing.
  3. Bot's polling-loop "no accounts" branch no longer exits in non-optional mode, so a mid-run config loss turns into a 5s-cadence error log.

None are blockers. LGTM once the volume comment is corrected or the mount is narrowed back.


Generated by Claude Code

Comment thread docker-compose.dev.yml
Comment on lines +24 to +26
# Local dev uses postgres:latest; mounting the parent dir keeps pace with
# versioned PGDATA paths like /var/lib/postgresql/<major>/docker.
- postgres-data-dev:/var/lib/postgresql
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment's premise is incorrect: the official postgres Docker image hard-codes PGDATA=/var/lib/postgresql/data regardless of major version (the /<major>/docker layout is Debian's system package, not this image). Widening to /var/lib/postgresql still works but also captures the postgres user's home dir in the volume, and masks whatever actual bug motivated the change.

If there's a real issue (permissions on a specific host? a transient initdb failure?), document that; otherwise revert to /var/lib/postgresql/data — it's narrower and correct for postgres:latest.


Generated by Claude Code

Comment thread dev.sh
Comment on lines +25 to +30
fi

if [ -f "$ENV_FILE" ]; then
local line
line=$(grep -E "^${key}=" "$ENV_FILE" | tail -n 1 || true)
if [ -n "$line" ]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${line#*=} returns the raw RHS including surrounding quotes and trailing comments. So FOO="bar" yields "bar" (literal quotes) and FOO=bar # note yields bar # note.

For the three keys checked here, -n still evaluates true so has_nonempty_env_value is correct in practice — but the moment this helper is used to print a value (or to compare against a literal), it bites. Either narrow it to a presence-check (grep -qE "^${key}=.\+") or strip quotes/comments.


Generated by Claude Code

}
console.error('No agent tokens configured. Set COMMONLY_AGENT_TOKEN or COMMONLY_AGENT_CONFIG_PATH.');
isPolling = false;
return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subtle behavior change: previously, !optionalRuntime + zero accounts was impossible inside the polling loop because startup already called process.exit(1). Now, if the runtime config file disappears mid-run (e.g. user deletes runtime.json), this branch fires every tick and logs "No agent tokens configured" indefinitely instead of failing loudly.

Low-probability in practice, but either exit here too (match startup semantics) or rate-limit the log like logWaitingForAccounts does.


Generated by Claude Code

@samxu01
Copy link
Copy Markdown
Contributor

samxu01 commented Apr 21, 2026

Feel free to ignore nit comments and merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants