Skip to content

fix(docker): run as non-root so claude bypassPermissions works - #14

Merged
krrish-berri-2 merged 1 commit into
mainfrom
fix/dockerfile-non-root-user
Apr 28, 2026
Merged

krrish-berri-2 merged 1 commit into
mainfrom
fix/dockerfile-non-root-user

Conversation

@krrish-berri-2

Copy link
Copy Markdown
Contributor

Summary

Followup to #11 / #12. Latest deploy got past no_skill, surfaced:

karpathy_failed pr=26610 err=no_json rc=1 stderr_tail=
--dangerously-skip-permissions cannot be used with root/sudo privileges for security reasons

karpathy_check.py hard-codes --permission-mode bypassPermissions in _invoke_claude(), and claude refuses that mode under uid 0. The container was inheriting the default root user from python:3.12-slim, so every karpathy invocation aborted before producing any JSON.

Fix

  • Create a bot user (uid 1000) with --create-home.
  • Clone /opt/litellm as bot so per-call git fetch origin pull/N/head and git worktree add succeed without sudo.
  • Install claude under bot's $HOME so the binary lives at /home/bot/.local/bin/claude — the path the runtime user can actually exec.
  • USER bot before CMD.

/app stays root-owned — bot only needs read access there, karpathy's per-call tempdirs go to /tmp, and _persist_run writes to Postgres rather than disk.

Test plan

Made with Cursor

Latest deploy logs:
  karpathy_failed pr=26610 err=no_json rc=1 stderr_tail=
  --dangerously-skip-permissions cannot be used with root/sudo
  privileges for security reasons

karpathy_check.py hard-codes `--permission-mode bypassPermissions` in
_invoke_claude(), and claude refuses that mode under uid 0. The
container was inheriting the default root user from python:3.12-slim,
so every karpathy invocation aborted before producing any JSON.

Fix: create a `bot` user (uid 1000), install claude under bot's $HOME
so the binary lives where the runtime user can exec it, chown
/opt/litellm to bot so per-call `git fetch` / `git worktree add`
succeed without sudo, and `USER bot` before CMD.

/app stays root-owned — bot only needs read access there; karpathy's
per-call tempdirs go to /tmp.

Made-with: Cursor
@krrish-berri-2
krrish-berri-2 merged commit 2891570 into main Apr 28, 2026
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.

1 participant