Archon/docker-entrypoint.sh
Leex a7337d6977 fix(docker): create /.archon subdirs in entrypoint for bind mounts (#1260)
Named volumes inherit /.archon/workspaces and /.archon/worktrees from the
image layer on first run, but bind mounts do not. Without these directories,
the Claude subprocess is spawned with a non-existent cwd and fails silently,
causing the 60s first-event timeout.

Adding mkdir -p in the entrypoint is idempotent for named volumes and fixes
bind-mount setups (e.g. ARCHON_DATA pointing to a host path on macOS/Linux).
2026-04-17 12:40:13 +02:00

32 lines
1.3 KiB
Bash

#!/bin/bash
set -e
# Ensure required subdirectories exist.
# Named volumes inherit these from the image layer on first run; bind mounts do not,
# which causes the Claude subprocess to fail silently when spawned with a missing cwd.
mkdir -p /.archon/workspaces /.archon/worktrees
# Determine if we need to use gosu for privilege dropping
if [ "$(id -u)" = "0" ]; then
# Running as root: fix volume permissions, then drop to appuser
if ! chown -Rh appuser:appuser /.archon 2>/dev/null; then
echo "ERROR: Failed to fix ownership of /.archon — volume may be read-only or mounted with incompatible options" >&2
exit 1
fi
RUNNER="gosu appuser"
else
# Already running as non-root (e.g., --user flag or Kubernetes)
RUNNER=""
fi
# Configure git to use GH_TOKEN for HTTPS clones via credential helper
# Uses a helper function so the token stays in the environment, not in ~/.gitconfig
if [ -n "$GH_TOKEN" ]; then
$RUNNER git config --global credential."https://github.com".helper \
'!f() { echo "username=x-access-token"; echo "password=${GH_TOKEN}"; }; f'
fi
# Run setup-auth (exits after configuring Codex credentials), then exec the server
# exec ensures bun is PID 1 and receives SIGTERM for graceful shutdown
$RUNNER bun run setup-auth
exec $RUNNER bun run start