From f33f12ef3ce0253206fd417b0ffb6a3f723c713e Mon Sep 17 00:00:00 2001 From: Mikei386 <44135113+Mikei386@users.noreply.github.com> Date: Wed, 14 Oct 2026 20:15:15 +0200 Subject: [PATCH] Document and add isolated OpenCode BuildKit image builder --- integrations/opencode-athena/BUILDKIT.md | 56 ++++++++++++++++++++++++ integrations/opencode-athena/build-image | 14 ++++++ 2 files changed, 70 insertions(+) create mode 100644 integrations/opencode-athena/BUILDKIT.md create mode 100644 integrations/opencode-athena/build-image diff --git a/integrations/opencode-athena/BUILDKIT.md b/integrations/opencode-athena/BUILDKIT.md new file mode 100644 index 0000000..2a54ac5 --- /dev/null +++ b/integrations/opencode-athena/BUILDKIT.md @@ -0,0 +1,56 @@ +# OpenCode isolated image builder — 2026-10-14 + +OpenCode uses a separate rootless `OpenCode-BuildKit` container on Unraid. +No host Docker socket, SSH identity, host network or workspace mount is supplied +to the builder. OpenCode transfers the requested build context through a Unix +socket. Build contexts must exclude secrets and irrelevant files via `.dockerignore`. + +Image: `moby/buildkit:rootless@sha256:65eca3c01cd1180c8f64565c4e3c5983af5145818b0e6fa863385d099eb73855`. +Restart policy `unless-stopped`, bridge network, no published ports, 4 GiB RAM, +2 CPU equivalents. Non-privileged, UID 1000. Rootless operation requires +`seccomp=unconfined` and `systempaths=unconfined` on this container only. +Uses native snapshotter; no host Docker daemon access. Build processes still +share the host kernel. This is not a VM or unrestricted Docker-in-Docker. + +Persistent host mounts: + +- `/mnt/nvme-storage/appdata/OpenCode/buildkit/socket` → `/run/user/1000/buildkit` +- `/mnt/nvme-storage/appdata/OpenCode-BuildKit/cache` → `/home/user/.local/share/buildkit` + +Both mount roots owned by UID/GID 1000; socket directory mode 0700. +Daemon arguments: `--addr unix:///run/user/1000/buildkit/buildkitd.sock +--oci-worker-snapshotter=native`. +Copy `/usr/bin/buildctl` from that pinned image into the existing OpenCode home +at `/root/buildkit/bin/buildctl`; install adjacent `build-image` from this repo. +These survive OpenCode recreation because `/root` is already persistent. + +Usage in OpenCode shell: + +```sh +cd /workspace/CasaDePrompt +/root/buildkit/bin/build-image casadeprompt:local ./casadeprompt-image.tar +``` + +The output is a Docker-loadable image archive, not an image installed in +Unraid's Docker daemon. No production container is started/replaced. A user or +administrator can later import the archive with `docker load`. +The client does not provide runtime container management. + +Restore on Unraid: recreate the pinned builder with the settings above, +restore OpenCode's home (client/wrapper/instructions) and cache if desired. +Cache is disposable; do not restore an old live socket inode. Stop the builder +before copying its cache. These Unraid files are not included automatically in +Athena Deck's encrypted backup. For future native Debian OpenCode, install the +pinned BuildKit binaries and RootlessKit for a dedicated non-root user, adjust +client socket path and supervise the rootless daemon with a user systemd unit. +That native installation and full-host restore have not been tested. + +Unraid GUI template: `/boot/config/plugins/dockerMan/templates-user/my-OpenCode-BuildKit.xml`. +OpenCode global AGENTS.md contains the exact persistent wrapper path. No restart +was performed; an already active agent turn may retain previously loaded instructions. + +Validation: builder worker reachable from OpenCode; BusyBox 1.37.0 Dockerfile +built with an actual `RUN` instruction creating `/proof.txt`. Exported archive +manifest and layer inspected independently; marker content matched `BUILD_OK`. +Only own temporary smoke context/archive removed afterward. CasaDePrompt itself +was not built or deployed in this integration check. diff --git a/integrations/opencode-athena/build-image b/integrations/opencode-athena/build-image new file mode 100644 index 0000000..060a094 --- /dev/null +++ b/integrations/opencode-athena/build-image @@ -0,0 +1,14 @@ +#!/bin/sh +set -eu +if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then + echo 'Usage: /root/buildkit/bin/build-image IMAGE_TAG [OUTPUT_TAR]' >&2 + exit 2 +fi +tag=$1 +out=${2:-./image.tar} +case "$tag$out" in *','*) echo 'Commas are not supported in tag/output path' >&2; exit 2;; esac +test -f Dockerfile || { echo 'Run from the project directory containing Dockerfile' >&2; exit 2; } +exec /root/buildkit/bin/buildctl \ + --addr unix:///root/buildkit/socket/buildkitd.sock build \ + --frontend dockerfile.v0 --local context=. --local dockerfile=. \ + --output "type=docker,name=$tag,dest=$out"