Sign inSign up

andresfr/opencode-ubuntu-sandbox

By andresfr

•Updated 7 months ago

Sandbox to run LLMs via OpenCode.

Image
Machine learning & AI
Developer tools
Data science
0

268

andresfr/opencode-ubuntu-sandbox repository overview

⁠Ubuntu-based sandbox to run LLMs via OpenCode

This container takes a basic Ubuntu image and adds minimal dependencies on top to run:

  • OpenCode and its free LLMs
  • OpenAI Codex
  • Miniconda

In particular, it allows browser-based authentication from the host, overcoming this issue⁠ in a fully self-contained manner. Support for other LLM vendors can be easily added.

Usage example (from a Linux host):

# create a session temporary dir inside the host
SESSION_DIR=$(mktemp -d /tmp/opencode_session-XXXXXX) && chmod 1777 "$SESSION_DIR"

# run container with port forwarding (needed for Codex OAuth), and mounting tmp, project1 and project2 from the host
docker run --rm -it -p 1455:1456 \
  -v "$HOME/miniconda3/envs:/opt/miniconda/envs" \
  -v "$PWD/opencode_full_config.json:/workspace/opencode.json:ro" \
  -e OPENCODE_CONFIG=/workspace/opencode.json \
  -v "$SESSION_DIR:/tmp" \
  -v "$HOME/project1:/workspace/project1" \
  -v "$HOME/project2:/workspace/project2" \
  --name opencode-ubuntu-sandbox opencode-ubuntu-sandbox:conda_codex

Now we can run opencode inside the container. The LLMs should be able to use our mounted conda environments and read and modify the tmp, project1 and project2 folders from the host. The host should also be able to read and modify them in parallel.

If your LLM requires a subscription, you can login via (inside container):

opencode auth login

To open a different terminal inside the same container:

docker exec -it <CONTAINER_NAME> bash

RECOMMENDED: it is also possible to store opencode sessions persistently, and to streamline work with more convenient commands such as:

# start opencode inside container and mount project1 and project2
# the -S flag "shares" local opencode config, so auth login and previous sessions are also mounted.
# The -E flag mounts the conda environments
llmsandbox -S -E ~/miniconda3/envs /path/to/project1 /path/to/project2

More info in this blog entry⁠

Tag summary

Content type

Image

Digest

sha256:2fe78e256…

Size

1.3 GB

Last updated

7 months ago

docker pull andresfr/opencode-ubuntu-sandbox:conda_codex