Replace docker compose with persistent per-project lifecycle

Move from docker compose run to a Python-managed container lifecycle.
Each project now gets a dedicated container that is started on demand
and stopped when opencode exits, instead of being recreated each time.

Use a shared home directory across projects so configurations presist.

The container are not destroyed, so tools and caches can be installed
specifically for a project by opencode itself once and reused, while
still avoiding long-running containers.
This commit is contained in:
Jeena 2026-01-21 21:33:30 +09:00
parent 57ef6454c6
commit fc2e5b1bca
4 changed files with 168 additions and 49 deletions

View file

@ -1,17 +1,5 @@
OPENCODE_CONTAINER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
opencode() {
local uid=$(id -u)
local gid=$(id -g)
local user=$(whoami)
UID="$uid" \
GID="$gid" \
USER="$user" \
CONTAINER_HOME="$OPENCODE_CONTAINER_DIR/container-home" \
docker compose \
-f "$OPENCODE_CONTAINER_DIR/docker-compose.yaml" \
run --rm \
-u "$uid:$gid" \
opencode opencode "$@" \
2> >(grep -v "No services to build" >&2)
python3 "$OPENCODE_CONTAINER_DIR/opencode-container.py" "$@"
}