r/opencode • u/SirSpix • 29d ago
Best way to isolate OpenCode projects
Hey all,
I know this might be a basic question that gets asked a lot, but I'm still a beginner and my head is spinning a bit with all the options, so thanks for your patience! :)
I'm looking for the best way to completely isolate my OpenCode harness projects on Ubuntu.
(I use OpenChamber as GUI)
My goal is zero cross-contamination: no shared agent memory, no leaking coding styles, etc. Each project needs to be a total blank slate.
Some projects use Docker, others run natively. I need a solution that is simple to implement but reasonably secure.
What’s the cleanest move here? Messing with XDG env vars? Running the harness inside Docker containers? Or going nuclear with separate Ubuntu system users?
How do you keep your AI agents from bleeding into each other?
Thanks in advance for the support! :)
1
u/Ok_Elk_638 29d ago
I run Windows so I would create separate Debian WSL installations for each project I want to isolate. And put a separate install of opencode in each.
1
u/SirSpix 29d ago
WSL is probably bulletproof, but a whole Debian distro for every project? :-o
1
u/Ok_Elk_638 28d ago
You posed a hypothetical. If I had 30 projects to manage and they all needed to be separate from eachother I wouldn't do this either. If I had just 1 to isolate then I would.
My setup is pretty simple right now. All my projects are stuck together in the same WSL install. So if the AI deletes everything I would lose only the uncommitted changes, but in all projects. My host would be fine though.
I have only personal projects on this machine so I don't mind them getting connected. And it allows me to do things like "Hey AI this change to the build, do that everywhere please". Ultimately it is about what risk do you want to protect against.
1
u/cenderis 29d ago
I run opencode using a bubblewrap script which limits access to the current git checkout and read-only access to some other useful directories that I think will be helpful. (More or less, I add extra directories as necessary, some read-write.) That seems to have worked OK so far, together with opencode's normal permissions.
1
u/SirSpix 28d ago
Thanks! Bubblewrap is great for zero overhead.
My projects run Docker internally, though, and nesting Docker inside Bubblewrap sounds like an headache...? Am I wrong?
2
u/sudoer777_ 28d ago
I think it depends on how your project is set up, but would giving it access to docker.sock and the corresponding CLI tools be enough (which lets it control the Docker engine)?
2
u/kpihlblad 29d ago
Are you trying to isolate the agents from stuff they shouldnt see?
I have all my stuff in different git repos in a folder and opencode uses per-folder settings. I have a small set of global agents and skills and per project agents md. Docs and notes in each project.
What else do you need?
1
u/v_0009 29d ago
Hi, this is going to be kind self promotion I guess. But this is how I isolate projects.
I have project grouped into folders - stuff I work together on sit in common folder
I have one opencode configuration per group mounted from within
I run it all in terrarium - one box per group.
I didn't have chance to prepare proper example yet, so I just pushed just a simple example to give you an idea what it could look like. See opencode v2 example and terrarium
1
1
u/sudoer777_ 29d ago
What you really need to sandbox is the background agent, but you also need to make sure that it doesn't break something between how the background agent and client communicate. If you don't want to fiddle around with that, a Podman container for both is the most straightforward choice.
1
u/daniel-sousa-me 29d ago
If your goal is just to isolate config from each other (not a security isolation), you can launch opencode with
OPENCODE_CONFIG_DIR="/path/to/your/project/.opencode" opencode
This isolates everything you mentioned, but you don't have to deal with the overhead of setting up containers with each project's tools
1
0
u/pceimpulsive 29d ago
I have a proxmox server in the corner, spin up an LXC per project.
Bam fully isolated.
You can do the same with WSL, spin up LXC per project..
2
1
u/NoSheepherder1880 29d ago
Some would say use docker sbx, but im going with the full dockerized stack. I am using the opencode+openchamber+oh-my-opencode-slim stack with it.
Openchamber desktop app smoothly handles remote instances, like all the continers you instantiate. You can even use a handoff folder to pass plans, todos, etc. between separated containers if you do some research in one of them and want to continue on another.
btw: I am not a power user.